|
|
@ -480,28 +480,20 @@ clear clearVars |
|
|
|
|
|
|
|
% ========== UNITS IMPLEMENTATION END ========== |
|
|
|
|
|
|
|
%% ========== TRANSFER FUNCTIONS START ========== |
|
|
|
|
|
|
|
%{ |
|
|
|
total_gain = units_filter_central_frequency_gain(1,1)* ... |
|
|
|
units_filter_central_frequency_gain(1,2)* ... |
|
|
|
units_filter_central_frequency_gain(1,3)* ... |
|
|
|
units_filter_central_frequency_gain(1,4); |
|
|
|
%} |
|
|
|
%% ========== TRANSFER FUNCTIONS STUDY START ========== |
|
|
|
|
|
|
|
total_transfer_function = series(series(series( ... |
|
|
|
unit_transfer_function(1), unit_transfer_function(2)), ... |
|
|
|
unit_transfer_function(3)), unit_transfer_function(4)); |
|
|
|
|
|
|
|
%total_transfer_function = total_transfer_function*(1/total_gain); |
|
|
|
|
|
|
|
%plot_transfer_function(unit_transfer_function(2), [1 10]); |
|
|
|
%ltiview(unit_transfer_function(1), unit_transfer_function(2), ... |
|
|
|
% unit_transfer_function(3), unit_transfer_function(4), total_transfer_function); |
|
|
|
|
|
|
|
%ltiview(total_transfer_function); |
|
|
|
|
|
|
|
%{ |
|
|
|
% Plots each unit's frequency response |
|
|
|
for i=1:band_pass_number_of_poles |
|
|
|
plot_transfer_function(unit_transfer_function(1,i), ... |
|
|
|
design_geometric_central_radial_frequency); |
|
|
|
end |
|
|
|
|
|
|
|
% Plots the total filter frequency response |
|
|
|
plot_transfer_function(total_transfer_function, ... |
|
|
|
[specification_low_stop_frequency ... |
|
|
|
specification_low_pass_frequency ... |
|
|
@ -509,9 +501,90 @@ plot_transfer_function(total_transfer_function, ... |
|
|
|
941.83 ... |
|
|
|
specification_high_pass_frequency ... |
|
|
|
specification_high_stop_frequency]); |
|
|
|
|
|
|
|
% Plots the total filter attenuation function |
|
|
|
plot_transfer_function(inv(total_transfer_function), ... |
|
|
|
[specification_low_stop_frequency ... |
|
|
|
specification_low_pass_frequency ... |
|
|
|
specification_central_frequency ... |
|
|
|
941.83 ... |
|
|
|
specification_high_pass_frequency ... |
|
|
|
specification_high_stop_frequency]); |
|
|
|
%} |
|
|
|
%{ |
|
|
|
ltiview(unit_transfer_function(1,1)); |
|
|
|
ltiview(unit_transfer_function(1,2)); |
|
|
|
ltiview(unit_transfer_function(1,3)); |
|
|
|
ltiview(unit_transfer_function(1,4)); |
|
|
|
ltiview(total_transfer_function); |
|
|
|
ltiview(unit_transfer_function(1,1), unit_transfer_function(1,2), ... |
|
|
|
unit_transfer_function(1,3), unit_transfer_function(1,4), ... |
|
|
|
total_transfer_function); |
|
|
|
%} |
|
|
|
|
|
|
|
hold off |
|
|
|
|
|
|
|
sampling_time_seconds = 60; % s |
|
|
|
sampling_frequency_Fs = 80000; % Hz |
|
|
|
sampling_period_T = 1/sampling_frequency_Fs; % s |
|
|
|
sampling_time_vector = 0:sampling_period_T: ... |
|
|
|
sampling_time_seconds-sampling_period_T; |
|
|
|
sampling_length_L = length(sampling_time_vector); |
|
|
|
frequency_vector = sampling_frequency_Fs/sampling_length_L* ... |
|
|
|
(0:(sampling_length_L/2)); |
|
|
|
|
|
|
|
input_cos_signal_frequency_1 = specification_central_radial_frequency- ... |
|
|
|
(specification_central_radial_frequency- ... |
|
|
|
specification_low_pass_radial_frequency)/2; |
|
|
|
input_cos_signal_frequency_2 = specification_central_radial_frequency+ ... |
|
|
|
(specification_central_radial_frequency+ ... |
|
|
|
specification_low_pass_radial_frequency)/3; |
|
|
|
input_cos_signal_frequency_3 = 0.4*specification_low_stop_radial_frequency; |
|
|
|
input_cos_signal_frequency_4 = 2.5*specification_high_stop_radial_frequency; |
|
|
|
input_cos_signal_frequency_5 = 3*specification_high_stop_radial_frequency; |
|
|
|
|
|
|
|
input_signal = cos(input_cos_signal_frequency_1*sampling_time_vector)+ ... |
|
|
|
0.8*cos(input_cos_signal_frequency_2*sampling_time_vector)+ ... |
|
|
|
0.8*cos(input_cos_signal_frequency_3*sampling_time_vector)+ ... |
|
|
|
0.6*cos(input_cos_signal_frequency_4*sampling_time_vector)+ ... |
|
|
|
0.5*cos(input_cos_signal_frequency_5*sampling_time_vector); |
|
|
|
|
|
|
|
[gain,phase] = ... |
|
|
|
bode(total_transfer_function, ... |
|
|
|
850*2*pi); |
|
|
|
|
|
|
|
system_output = lsim(total_transfer_function, input_signal, ... |
|
|
|
sampling_time_vector); |
|
|
|
|
|
|
|
% Plots only the first 2000 samples |
|
|
|
figure(1) |
|
|
|
plot(sampling_time_vector(1:2000), input_signal(1:2000), ... |
|
|
|
sampling_time_vector(1:2000), system_output(1:2000)); |
|
|
|
grid on |
|
|
|
|
|
|
|
|
|
|
|
% Plots the power spectrum of the input signal |
|
|
|
input_square_wave_fft = fft(input_signal); |
|
|
|
Pyy = input_square_wave_fft.*conj(input_square_wave_fft)/sampling_length_L; |
|
|
|
figure(2) |
|
|
|
semilogx(frequency_vector,Pyy(1:sampling_length_L/2+1)) |
|
|
|
grid on |
|
|
|
|
|
|
|
|
|
|
|
% Plots the power spectrum of the output signal |
|
|
|
system_output_fft = fft(system_output, length(sampling_time_vector)); |
|
|
|
Pyy = system_output_fft.*conj(system_output_fft)/sampling_length_L; |
|
|
|
figure(3) |
|
|
|
semilogx(frequency_vector,Pyy(1:sampling_length_L/2+1)) |
|
|
|
grid on |
|
|
|
|
|
|
|
% Clears unneeded variables from workspace |
|
|
|
clearVars = {'temp', 'Pyy', 'frequency_vector', ... |
|
|
|
'system_output', 'system_output_fft'}; |
|
|
|
clear(clearVars{:}) |
|
|
|
clear clearVars |
|
|
|
clear -regexp _transfer_function$ |
|
|
|
clear -regexp ^sampling_ |
|
|
|
%clear -regexp ^input_ |
|
|
|
|
|
|
|
% ========== TRANSFER FUNCTIONS END ========== |
|
|
|
% ========== TRANSFER FUNCTIONS STUDY END ========== |