89 lines
2.8 KiB
Matlab
89 lines
2.8 KiB
Matlab
|
|
|
|
% load dp_freqresp
|
|
path = 'C:\Users\Silas\Documents\MATLAB\mmgl\projects\S21';
|
|
%path = 'C:\Users\Silas\Documents\MATLAB\model-collection\sioe_models\Filter Comparison';
|
|
% name = 'precomp_golden.mat';
|
|
name = 'dpe_el_b2b_m8199b_uxr1102A_loop1_1_1mmKabel.mat';
|
|
%name = 'cable_loop0_1.mat';
|
|
data = load([path,filesep,name]);
|
|
|
|
field = data.uFF;
|
|
|
|
field_abs = fftshift(20*log10(abs(1./field)));
|
|
|
|
field_atten_dc = field_abs(round(length(field_abs)/2));
|
|
sorted_data = sort(field_abs);
|
|
lower_index = round(0.1 * length(sorted_data)); % Lower 10%
|
|
upper_index = round(0.9 * length(sorted_data)); % Upper 90%
|
|
inner_values = sorted_data(lower_index+1 : upper_index);
|
|
average_inner = mean(inner_values);
|
|
|
|
field_angle = fftshift(angle(1./field));
|
|
|
|
frex = data.f .* 1e-9;
|
|
frex = linspace(-max(frex)/2,max(frex)/2,numel(frex));
|
|
field_grpdly = diff(unwrap(field_angle))./diff(frex);
|
|
|
|
|
|
%Filter for comparison
|
|
fc = 35;
|
|
n = 1;
|
|
|
|
if 0
|
|
%construct gaussian
|
|
faxis=linspace(-max(frex),max(frex),length(frex));%generates arow vector faxis of blocklen+1 points linearly spaced between and including -para.fs/2 and para.fs/2
|
|
faxis=ifftshift(faxis(1:end));
|
|
H=exp(-((faxis)/(fc*2)).^(2*n)*log(2)*2^(2*n-1));
|
|
filt = fftshift(20*log10(abs(H))).';
|
|
filtname = ['Gauss.; fc:',num2str(fc),' GHz, order: ',num2str(n)];
|
|
else
|
|
% add a butterworth filter
|
|
[B, A] = butter(n, fc/max(frex),'low');
|
|
[H,w]=freqz(B,A,length(frex),'whole');
|
|
filt = fftshift(20*log10(abs(H)));
|
|
filtname = ['Butterw.; fc:',num2str(fc),' GHz, order: ',num2str(n)];
|
|
end
|
|
|
|
filt = filt+sorted_data(upper_index);
|
|
filt_angle = fftshift(angle(H));
|
|
filt_grpdly = diff(unwrap(filt_angle))./diff(frex);
|
|
|
|
|
|
figure(12)
|
|
subplot(3,1,1);
|
|
hold on
|
|
p1 = plot(frex,field_abs,'LineWidth',1,'LineStyle','-','DisplayName',['s21: ', char(filename)]);
|
|
p2 = plot(frex,filt,'LineWidth',1,'LineStyle',':','DisplayName',filtname);
|
|
yline(-3,'LineStyle',':','LineWidth',1,'HandleVisibility','off');
|
|
yline(sorted_data(lower_index),'DisplayName','10% Percentile');
|
|
yline(sorted_data(upper_index),'DisplayName','90% Percentile');
|
|
yline(average_inner,'DisplayName','Avg. 10-90% Percentile');
|
|
ylim([-40 1])
|
|
ylabel('Magnitude (dB)')
|
|
legend
|
|
|
|
subplot(3,1,2);
|
|
hold on
|
|
p1 = plot(frex,field_angle,'LineWidth',1,'Color',p1.Color,'LineStyle','-','DisplayName',['s21 phase: ', char(filename)]);
|
|
p2 = plot(frex,filt_angle,'LineWidth',1,'Color',p2.Color,'LineStyle',':','DisplayName',filtname);
|
|
ylim([-pi,pi]);
|
|
yticks([-pi, 0, pi]);
|
|
yticklabels({'-$\pi$', '0', '$\pi$'});
|
|
ylabel('Angle');
|
|
grid minor
|
|
xlabel('Freq in GHz')
|
|
legend
|
|
|
|
|
|
subplot(3,1,3);
|
|
hold on
|
|
p1 = plot(frex(2:end),field_grpdly,'LineWidth',1,'Color',p1.Color,'LineStyle',':','DisplayName',['s21 phase: ', char(filename)]);
|
|
p2 = plot(frex(2:end),filt_grpdly,'LineWidth',1,'Color',p2.Color,'LineStyle',':','DisplayName',filtname);
|
|
ylabel('Group Delay (in s ??)');
|
|
grid minor
|
|
xlabel('Freq in GHz')
|
|
|
|
legend
|
|
|