Browse Source

Low pass response to input signal init

master
Apostolos Fanakis 6 years ago
parent
commit
8407b2a5d8
  1. 82
      Low Pass Inverse Chebyshev/low_pass_design.m

82
Low Pass Inverse Chebyshev/low_pass_design.m

@ -411,29 +411,95 @@ fprintf(['\n' '===== GAIN ADJUSTMENT =====' '\n' ...
% ========== GAIN ADJUSTMENT END ========== % ========== GAIN ADJUSTMENT END ==========
%% ========== TRANSFER FUNCTIONS START ========== %% ========== TRANSFER FUNCTIONS STUDY START ==========
total_transfer_function = series(unit_transfer_function(1,1), ... total_transfer_function = series(unit_transfer_function(1,1), ...
unit_transfer_function(1,2)); unit_transfer_function(1,2));
total_transfer_function = total_transfer_function*unit_adjustment_gain; total_transfer_function = total_transfer_function*unit_adjustment_gain;
low_frequency = 10;
%{ %{
% Plots each unit's frequency response
for i=1:design_number_of_poles
plot_transfer_function(unit_transfer_function(1,i), ...
(low_frequency));
end
% Plots the total filter frequency response
plot_transfer_function(total_transfer_function, ... plot_transfer_function(total_transfer_function, ...
[10 ... [low_frequency ...
specification_pass_frequency ... specification_pass_frequency ...
design_half_power_radial_frequency/(2*pi) ... design_half_power_radial_frequency/(2*pi) ...
specification_stop_frequency]); specification_stop_frequency]);
% Plots the total filter attenuation function
plot_transfer_function(inv(total_transfer_function), ...
[low_frequency ...
specification_pass_frequency ...
design_half_power_radial_frequency/(2*pi) ...
specification_stop_frequency]);
%}
%{
ltiview(unit_transfer_function(1,1));
ltiview(unit_transfer_function(1,2));
ltiview(total_transfer_function);
ltiview(unit_transfer_function(1,1), unit_transfer_function(1,2), ...
total_transfer_function);
%} %}
%ltiview(unit_transfer_function(1,1)); hold off
%ltiview(unit_transfer_function(1,2));
%ltiview(total_transfer_function); Fs = 1000; % Sampling frequency
%ltiview(unit_transfer_function(1,1), unit_transfer_function(1,2), ... T = 1/Fs; % Sampling period
%total_transfer_function); L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
input_signal_frequency = 2000; % Hz
input_signal_number_of_periods = 100000;
input_signal_T = input_signal_number_of_periods*(1/input_signal_frequency);
input_signal_duty_cycle = 20;
input_signal_Fs = 80000;
input_signal_dt = 1/input_signal_Fs;
input_signal_t = 0:input_signal_dt:input_signal_T-input_signal_dt;
input_square_wave = (1+square(2*pi*input_signal_frequency*input_signal_t, ...
input_signal_duty_cycle))/2;
system_output = lsim(total_transfer_function, input_square_wave, input_signal_t);
% Plots only the first 10 periods
temp = 10*input_signal_Fs/input_signal_frequency;
figure(1)
plot(input_signal_t(1:temp), input_square_wave(1:temp), ...
input_signal_t(1:temp), system_output(1:temp));
grid on
input_square_wave_fft = fft(input_square_wave);
L = length(input_signal_t);
P2 = abs(input_square_wave_fft/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = input_signal_Fs*(0:(L/2))/L;
figure(2)
%plot(f,P1)
semilogx(f,P1)
grid on
system_output_fft = fft(system_output, length(input_signal_t));
P2 = abs(system_output_fft/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
figure(3)
%plot(f, P11)
semilogx(f,P1)
grid on
%filter_fft = fft(total_transfer_function);
% Clears unneeded variable from workspace % Clears unneeded variable from workspace
clear low_frequency
clear -regexp _numerator$ clear -regexp _numerator$
clear -regexp _denominator$ clear -regexp _denominator$
clear -regexp _transfer_function$ clear -regexp _transfer_function$
clear -regexp ^input_signal_
% ========== TRANSFER FUNCTIONS END ========== % ========== TRANSFER FUNCTIONS STUDY END ==========
Loading…
Cancel
Save