Many changes towards simulation of JLT and once again the evaluation of the Highspeed data from Lab experiments 2024
This commit is contained in:
64
Functions/Theory/analyze_moving_average_filter.m
Normal file
64
Functions/Theory/analyze_moving_average_filter.m
Normal file
@@ -0,0 +1,64 @@
|
||||
% Parameters
|
||||
N_values = [10 100 1000 4096]; % Different filter lengths to analyze
|
||||
fs = 112e9;
|
||||
|
||||
% Create figure
|
||||
figure;
|
||||
|
||||
% Plot frequency responses
|
||||
subplot(211)
|
||||
hold on
|
||||
grid on
|
||||
ylabel('Magnitude (dB)')
|
||||
title('Frequency Response')
|
||||
yline(-3,'--r')
|
||||
ylim([-40 5])
|
||||
|
||||
subplot(212)
|
||||
hold on
|
||||
grid on
|
||||
xlabel('Frequency (GHz)')
|
||||
ylabel('Phase (rad)')
|
||||
title('Phase Response')
|
||||
|
||||
% Color map for different lines
|
||||
colors = cbrewer2('Set1',length(N_values));
|
||||
|
||||
% Loop through different filter lengths
|
||||
for i = 1:length(N_values)
|
||||
N = N_values(i);
|
||||
|
||||
% Filter coefficients
|
||||
b = ones(1,N)/N;
|
||||
a = 1;
|
||||
|
||||
% Frequency response
|
||||
[h,w] = freqz(b,a,4096*8);
|
||||
freq = (w/(2*pi))*fs;
|
||||
h_db = 20*log10(abs(h));
|
||||
|
||||
% Plot magnitude response
|
||||
subplot(211)
|
||||
plot(freq/1e9, h_db, 'Color', colors(i,:), 'DisplayName', sprintf('N=%d', N),'LineWidth',0.1)
|
||||
|
||||
% Plot phase response
|
||||
subplot(212)
|
||||
plot(freq/1e9, unwrap(angle(h)), 'Color', colors(i,:), 'DisplayName', sprintf('N=%d', N),'LineWidth',0.1)
|
||||
|
||||
% Find -3dB frequency
|
||||
cutoff_idx = find(h_db <= -3, 1);
|
||||
f_cutoff = freq(cutoff_idx)/1e9;
|
||||
fprintf('N=%d: Cutoff frequency (-3dB point): %.2f GHz\n', N, f_cutoff)
|
||||
end
|
||||
|
||||
% Add legend and adjust axes
|
||||
subplot(211)
|
||||
legend('show')
|
||||
xlim([0 16]) % Adjust x-axis limit to better see the differences
|
||||
|
||||
subplot(212)
|
||||
legend('show')
|
||||
xlim([0 16]) % Adjust x-axis limit to better see the differences
|
||||
|
||||
% Analytical approximation
|
||||
f_3db_approx = 0.443 * fs./N_values ./ 1e9;
|
||||
Reference in New Issue
Block a user