|
|
@ -774,14 +774,6 @@ unit_adjustment_gain = 1/total_gain_high; |
|
|
|
% unit |
|
|
|
unit_adjustment_feedback_resistor = 10*10^3*unit_adjustment_gain; |
|
|
|
|
|
|
|
total_transfer_function = series(series(series( ... |
|
|
|
high_pass_notch_units_transfer_functions(1,1), ... |
|
|
|
high_pass_notch_units_transfer_functions(1,2)), ... |
|
|
|
low_pass_notch_units_transfer_functions(1,1)), ... |
|
|
|
low_pass_notch_units_transfer_functions(1,2)); |
|
|
|
|
|
|
|
total_transfer_function = total_transfer_function*unit_adjustment_gain; |
|
|
|
|
|
|
|
fprintf(['\n' '===== GAIN ADJUSTMENT =====' '\n' ... |
|
|
|
'A gain adjustment unit is needed to achieve 0dB attenuation at ' ... |
|
|
|
'pass band.\n' ... |
|
|
@ -791,48 +783,117 @@ fprintf(['\n' '===== GAIN ADJUSTMENT =====' '\n' ... |
|
|
|
|
|
|
|
% ========== GAIN ADJUSTMENT END ========== |
|
|
|
|
|
|
|
%% ========== TRANSFER FUNCTIONS START ========== |
|
|
|
|
|
|
|
%{ |
|
|
|
ltiview(high_pass_notch_units_transfer_functions(1,1), ... |
|
|
|
high_pass_notch_units_transfer_functions(1,2)); |
|
|
|
%} |
|
|
|
%% ========== TRANSFER FUNCTIONS STUDY START ========== |
|
|
|
|
|
|
|
%{ |
|
|
|
ltiview(low_pass_notch_units_transfer_functions(1,1), ... |
|
|
|
total_transfer_function = series(series(series( ... |
|
|
|
high_pass_notch_units_transfer_functions(1,1), ... |
|
|
|
high_pass_notch_units_transfer_functions(1,2)), ... |
|
|
|
low_pass_notch_units_transfer_functions(1,1)), ... |
|
|
|
low_pass_notch_units_transfer_functions(1,2)); |
|
|
|
%} |
|
|
|
|
|
|
|
%{ |
|
|
|
ltiview(high_pass_notch_units_transfer_functions(1,1), ... |
|
|
|
high_pass_notch_units_transfer_functions(1,2), ... |
|
|
|
low_pass_notch_units_transfer_functions(1,1), ... |
|
|
|
low_pass_notch_units_transfer_functions(1,2)); |
|
|
|
%} |
|
|
|
total_transfer_function = total_transfer_function*unit_adjustment_gain; |
|
|
|
|
|
|
|
%{ |
|
|
|
ltiview(high_pass_notch_units_transfer_functions(1,1), ... |
|
|
|
high_pass_notch_units_transfer_functions(1,2), ... |
|
|
|
low_pass_notch_units_transfer_functions(1,1), ... |
|
|
|
low_pass_notch_units_transfer_functions(1,2), ... |
|
|
|
total_transfer_function); |
|
|
|
%} |
|
|
|
|
|
|
|
%ltiview(total_transfer_function); |
|
|
|
% Plots each unit's frequency response |
|
|
|
for i=1:band_elimination_number_of_poles |
|
|
|
if i==1 || i==3 |
|
|
|
plot_transfer_function( ... |
|
|
|
high_pass_notch_units_transfer_functions(1,(i+1)/2), ... |
|
|
|
(band_elimination_poles_radial_frequencies(1,i)/(2*pi))); |
|
|
|
else |
|
|
|
plot_transfer_function( ... |
|
|
|
low_pass_notch_units_transfer_functions(1,i/2), ... |
|
|
|
(band_elimination_poles_radial_frequencies(1,i)/(2*pi))); |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
%{ |
|
|
|
% Plots the total filter frequency response |
|
|
|
plot_transfer_function(total_transfer_function, ... |
|
|
|
[specification_low_stop_frequency ... |
|
|
|
specification_low_pass_frequency ... |
|
|
|
specification_central_frequency ... |
|
|
|
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 ... |
|
|
|
specification_high_pass_frequency ... |
|
|
|
specification_high_stop_frequency]); |
|
|
|
%} |
|
|
|
|
|
|
|
% Clears unneeded variable from workspace |
|
|
|
clearVars = {'total_transfer_function'}; |
|
|
|
|
|
|
|
%{ |
|
|
|
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_stop_radial_frequency)/2; |
|
|
|
input_cos_signal_frequency_2 = specification_central_radial_frequency+ ... |
|
|
|
(specification_central_radial_frequency+ ... |
|
|
|
specification_low_stop_radial_frequency)/3; |
|
|
|
input_cos_signal_frequency_3 = 0.4*specification_low_pass_radial_frequency; |
|
|
|
input_cos_signal_frequency_4 = 2.5*specification_high_pass_radial_frequency; |
|
|
|
input_cos_signal_frequency_5 = 3*specification_high_pass_radial_frequency; |
|
|
|
|
|
|
|
input_signal = 0.5*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)+ ... |
|
|
|
1.2*cos(input_cos_signal_frequency_5*sampling_time_vector); |
|
|
|
|
|
|
|
system_output = lsim(total_transfer_function, input_signal, ... |
|
|
|
sampling_time_vector); |
|
|
|
|
|
|
|
% Plots only the first 500 samples |
|
|
|
figure(1) |
|
|
|
plot(sampling_time_vector(1:500), input_signal(1:500), ... |
|
|
|
sampling_time_vector(1:500), system_output(1:500)); |
|
|
|
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', 'i' ... |
|
|
|
'system_output', 'total_transfer_function', 'system_output_fft'}; |
|
|
|
clear(clearVars{:}) |
|
|
|
clear clearVars |
|
|
|
clear -regexp ^sampling_ |
|
|
|
clear -regexp ^input_ |
|
|
|
clear -regexp _transfer_functions$ |
|
|
|
|
|
|
|
% ========== TRANSFER FUNCTIONS END ========== |
|
|
|
% ========== TRANSFER FUNCTIONS STUDY END ========== |