|
@ -198,8 +198,8 @@ for i=1:low_pass_prototype_number_of_poles |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
% Clears unneeded variables from workspace |
|
|
% Clears unneeded variables from workspace |
|
|
clearVars = {'i', 'prototype_normalized_stop_radial_frequency', ... |
|
|
clearVars = {'i', 'prototype_normalized_stop_radial_frequency', 'theta', ... |
|
|
'low_pass_prototype_half_power_radial_frequency', 'theta'}; |
|
|
'low_pass_prototype_half_power_radial_frequency', 'temp_filter_order'}; |
|
|
clear(clearVars{:}) |
|
|
clear(clearVars{:}) |
|
|
clear clearVars |
|
|
clear clearVars |
|
|
|
|
|
|
|
@ -340,12 +340,12 @@ for i=1:high_pass_number_of_poles |
|
|
% Builds unit's transfer function |
|
|
% Builds unit's transfer function |
|
|
% Builds numerator and denominator of the transfer function using the |
|
|
% Builds numerator and denominator of the transfer function using the |
|
|
% eq. 6-68 |
|
|
% eq. 6-68 |
|
|
G = (units_R(1,i)+units_r2(1,i))/units_R(1,i); |
|
|
temp_G = (units_R(1,i)+units_r2(1,i))/units_R(1,i); |
|
|
unit_numerator = [G ... |
|
|
unit_numerator = [temp_G ... |
|
|
0 ... |
|
|
0 ... |
|
|
0]; |
|
|
0]; |
|
|
unit_denominator = [1 ... |
|
|
unit_denominator = [1 ... |
|
|
2/(units_C(1,i)*units_R(1,i))+(1-G)/(units_C(1,i)*units_R(1,i)) ... |
|
|
2/(units_C(1,i)*units_R(1,i))+(1-temp_G)/(units_C(1,i)*units_R(1,i)) ... |
|
|
1/(units_C(1,i)^2*units_R(1,i)^2)]; |
|
|
1/(units_C(1,i)^2*units_R(1,i)^2)]; |
|
|
|
|
|
|
|
|
units_transfer_functions(1,i) = ... |
|
|
units_transfer_functions(1,i) = ... |
|
@ -375,52 +375,112 @@ for i=1:high_pass_number_of_poles |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
% Clears unneeded variables from workspace |
|
|
% Clears unneeded variables from workspace |
|
|
clearVars = {'i'}; |
|
|
clearVars = {'i', 'temp_G', 'unit_numerator', 'unit_denominator'}; |
|
|
clear(clearVars{:}) |
|
|
clear(clearVars{:}) |
|
|
clear clearVars |
|
|
clear clearVars |
|
|
clear -regexp _transfer_function$ |
|
|
|
|
|
|
|
|
|
|
|
% ========== UNITS IMPLEMENTATION END ========== |
|
|
% ========== UNITS IMPLEMENTATION END ========== |
|
|
|
|
|
|
|
|
%% ========== GAIN ADJUSTMENT START ========== |
|
|
%% ========== GAIN ADJUSTMENT START ========== |
|
|
|
|
|
|
|
|
% |
|
|
|
|
|
total_gain_high = units_k(1,1)*units_k(1,2); |
|
|
total_gain_high = units_k(1,1)*units_k(1,2); |
|
|
unit_adjustment_gain = 1/total_gain_high; |
|
|
unit_adjustment_gain = 1/total_gain_high; |
|
|
% We arbitrarily choose to use a 10KOhm series resistor in the adjustment |
|
|
% We arbitrarily choose to use a 10KOhm series resistor in the adjustment |
|
|
% unit |
|
|
% unit |
|
|
unit_adjustment_feedback_resistor = 10*10^3*unit_adjustment_gain; |
|
|
unit_adjustment_feedback_resistor = 10*10^3*unit_adjustment_gain; |
|
|
% |
|
|
|
|
|
|
|
|
% ========== GAIN ADJUSTMENT END ========== |
|
|
|
|
|
|
|
|
|
|
|
%% ========== TRANSFER FUNCTIONS STUDY START ========== |
|
|
|
|
|
|
|
|
total_transfer_function = series(units_transfer_functions(1,1), ... |
|
|
total_transfer_function = series(units_transfer_functions(1,1), ... |
|
|
units_transfer_functions(1,2)); |
|
|
units_transfer_functions(1,2)); |
|
|
total_transfer_function = total_transfer_function*unit_adjustment_gain; |
|
|
total_transfer_function = total_transfer_function*unit_adjustment_gain; |
|
|
|
|
|
|
|
|
|
|
|
% Arbitrary high frequency to display the gain at high frequencies |
|
|
|
|
|
high_frequency = 90000; % Hz |
|
|
%{ |
|
|
%{ |
|
|
ltiview(units_transfer_functions(1,1), ... |
|
|
% Plots each unit's frequency response |
|
|
units_transfer_functions(1,2)); |
|
|
for i=1:high_pass_number_of_poles |
|
|
%} |
|
|
plot_transfer_function(units_transfer_functions(1,i), ... |
|
|
|
|
|
(high_frequency)); |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
% Plots the total filter frequency response |
|
|
|
|
|
plot_transfer_function(total_transfer_function, ... |
|
|
|
|
|
[specification_stop_frequency ... |
|
|
|
|
|
design_half_power_radial_frequency/(2*pi) ... |
|
|
|
|
|
specification_pass_frequency ... |
|
|
|
|
|
high_frequency]); |
|
|
|
|
|
|
|
|
|
|
|
% Plots the total filter attenuation function |
|
|
|
|
|
plot_transfer_function(inv(total_transfer_function), ... |
|
|
|
|
|
[specification_stop_frequency ... |
|
|
|
|
|
design_half_power_radial_frequency/(2*pi) ... |
|
|
|
|
|
specification_pass_frequency ... |
|
|
|
|
|
high_frequency]); |
|
|
|
|
|
%} |
|
|
%{ |
|
|
%{ |
|
|
ltiview(units_transfer_functions(1,1), ... |
|
|
ltiview('bodemag', units_transfer_functions(1,1)); |
|
|
units_transfer_functions(1,2), ... |
|
|
ltiview('bodemag', units_transfer_functions(1,2)); |
|
|
|
|
|
ltiview('bodemag', total_transfer_function); |
|
|
|
|
|
ltiview('bodemag', units_transfer_functions(1,1), units_transfer_functions(1,2), ... |
|
|
total_transfer_function); |
|
|
total_transfer_function); |
|
|
%} |
|
|
%} |
|
|
|
|
|
|
|
|
%ltiview(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 = 0.2*specification_stop_radial_frequency; |
|
|
|
|
|
input_cos_signal_frequency_2 = 0.7*specification_stop_radial_frequency; |
|
|
|
|
|
input_cos_signal_frequency_3 = 1.6*specification_pass_radial_frequency; |
|
|
|
|
|
input_cos_signal_frequency_4 = 2.4*specification_pass_radial_frequency; |
|
|
|
|
|
input_cos_signal_frequency_5 = 3.5*specification_pass_radial_frequency; |
|
|
|
|
|
|
|
|
|
|
|
input_signal = cos(input_cos_signal_frequency_1*sampling_time_vector)+ ... |
|
|
|
|
|
0.6*cos(input_cos_signal_frequency_2*sampling_time_vector)+ ... |
|
|
|
|
|
1.5*cos(input_cos_signal_frequency_3*sampling_time_vector)+ ... |
|
|
|
|
|
0.7*cos(input_cos_signal_frequency_4*sampling_time_vector)+ ... |
|
|
|
|
|
0.4*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_signal_fft = fft(input_signal); |
|
|
|
|
|
Pyy = input_signal_fft.*conj(input_signal_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 |
|
|
|
|
|
|
|
|
%{ |
|
|
|
|
|
plot_transfer_function(total_transfer_function, ... |
|
|
|
|
|
[design_half_power_radial_frequency/(2*pi) ... |
|
|
|
|
|
specification_stop_frequency ... |
|
|
|
|
|
specification_pass_frequency ... |
|
|
|
|
|
15000]); |
|
|
|
|
|
%} |
|
|
|
|
|
|
|
|
|
|
|
% Clears unneeded variable from workspace |
|
|
% Clears unneeded variable from workspace |
|
|
clearVars = {'total_transfer_function'}; |
|
|
clearVars = {'high_frequency', 'total_transfer_function', 'Pyy', ... |
|
|
|
|
|
'frequency_vector', 'system_output', 'system_output_fft'}; |
|
|
clear(clearVars{:}) |
|
|
clear(clearVars{:}) |
|
|
clear clearVars |
|
|
clear clearVars |
|
|
clear -regexp _transfer_functions$ |
|
|
clear -regexp _transfer_functions$ |
|
|
|
|
|
clear -regexp ^sampling_ |
|
|
|
|
|
clear -regexp ^input_ |
|
|
|
|
|
|
|
|
% ========== GAIN ADJUSTMENT END ========== |
|
|
% ========== TRANSFER FUNCTIONS STUDY END ========== |