exercise 5.10
ZIP with MATLAB scripts and note:
exercise 5.10 notes:
Analytical solution with |s11| surface
Z0=50;ZL=Z0/(.4+1j*1.2);
D3=3/8;
Dstep=.0002;drange=[0:Dstep:.5];
D1=drange;D2=D1;
Zin4=zeros(numel(drange),numel(drange));
s11=zeros(numel(drange),numel(drange));
for k=1:1:numel(D1)
for s=1:1:numel(D2)
Zin_stub1=Z0*1j*tan(2*pi*D1(k));
Zin2=(Zin_stub1.^-1+ZL.^-1).^-1;
Zin3=Z0*(Zin2+1j*Z0*tan(2*pi*D3))./(Z0+1j*Zin2*tan(2*pi*D3));
Zin_stub2=Z0*1j*tan(2*pi*D2(s));
Zin4(k,s)=(Zin_stub2.^-1+Zin3.^-1).^-1;
s11(k,s)=(Zin4(k,s)-Z0)/(Zin4(k,s)+Z0);
end
end
hf1=figure(1);hs1=surf(D1,D2,abs(s11))
ax1=hf1.CurrentAxes;
hs1.LineStyle='none'
xlabel('D2');ylabel('D1')
campos(ax1,10*[0 0 100]);
camroll(ax1,-45)
ax1.PlotBoxAspectRatio=[1 1 1]
hold(ax1,'on')
n0=find(drange==.5) % plotting corner to box D1<.5 D2<.5
plot3(ax1,[drange(n0) drange(n0) 0],[0 drange(n0) drange(n0)],…
[5 5 5],'Color',[1 0 0],'LineWidth',3)
Conditioning surface to catch |s11| nulls
% V=1-(abs(s11));
V=10^3*del2(abs(s11));
hf2=figure(2);ax2=gca;surf(V,'Lines','none');xlabel('D1');ylabel('D2');
ax2.XTickLabelMode='manual';
ax2.YTickLabelMode='manual';
ax2.XTickLabel=[0:0.1:.5];ax2.YTickLabel=[0:0.1:.5];
[pks,locs]=findpeaks(V(:),'MinPeakHeight',.99,'MinPeakDistance',200);
[nd1,nd2]=ind2sub(size(V),locs);
hold all;plot3(nd2,nd1,V(nd2,nd1)+2,'ro'); % verifying peaks locations
plot3(ax2,[drange(n0) drange(n0) 0],[0 drange(n0) drange(n0)],…
[5 5 5],'Color',[1 0 0],'LineWidth',3)
Dstep=.0002;drange=[0:Dstep:.5];
D1=drange;D2=D1;
D1=unique(sort(D1(nd1)))
% same as
D1=drange;D2=D1;
D1=D1(unique(sort(nd1)))
D2=unique(sort(D2(nd2)))
D1 =
Columns 1 through 3
0.050600000000000 0.050800000000000 0.051000000000000
Columns 4 through 6
0.051200000000000 0.051400000000000 0.051600000000000
Columns 7 through 9
0.051800000000000 0.098600000000000 0.098800000000000
D1 =
Columns 1 through 3
0.050600000000000 0.050800000000000 0.051000000000000
Columns 4 through 6
0.051200000000000 0.051400000000000 0.051600000000000
Columns 7 through 9
0.051800000000000 0.098600000000000 0.098800000000000
D2 =
Columns 1 through 3
0.048600000000000 0.048800000000000 0.049000000000000
Columns 4 through 6
0.049200000000000 0.049400000000000 0.049600000000000
..
0.374400000000000 0.374600000000000 0.374800000000000
Columns 31 through 33
0.375000000000000 0.375200000000000 0.375400000000000
Columns 34 through 35
0.375600000000000 0.375800000000000
Now the quite different shape of the peaks returns a different amount of peak locations despite from both previous graphs one can tell that there are 2 clear |s11| nulls. Here is where function kmeans comes quite handy
On the right hand side, the closest that the above surface and chosen conditioning gets us to peaks locations, so far.
Since from |s11| it's highly likely that |s11| has 2 nulls within [0 .5] x [0 .5] wavelength fraction D, L stub ength, L=D*l , let's use kmeans with k=2.
locs1
=
608003
610504
613005
615506
618006
620507
623008
625509
628009
630510
633011
635512
638012
640513
643014
645514
648015
650516
653017
655517
658018
660519
663020
665520
668021
670522
locs2
=
4679866
4682367
4684868
4687369
4689870
4692370
4694871
4697372
4699873
locs3
=
1.037676749975155
1.127321441557838
1.219759148078254
1.307902495524382
1.436938848741699
1.626818258880166
1.828290158620465
2.008170018700442
2.327551443905220
2.920029348588793
3.609215877084772
4.005216276204536
4.917328558982023
10.188490651197503
5.714683330692673
3.641781956334297
3.487384399634491
2.877672242184274
2.296011113485124
1.878303169964850
1.711972650510920
1.518129552003200
1.332318001956141
1.185153344920222
1.096700695677261
1.005028697436138
locs4
=
1.022294122904170
1.288112420134564
1.616498278070448
1.813192017180561
1.479922650697164
1.467160456281476
1.526533687583176
1.328279542622017
1.096739121053541
[idx,C]=kmeans(locs,2) % grouping peaks locations
nlocs=[1:1:numel(locs)] % finging linear indices of peaks locations in locs
nlocs1=nlocs(idx==1) % linear indices of 1st peak locations in locs
nlocs2=nlocs(idx==2)
locs1=locs(nlocs1) % locations in surface of 1st group of peaks
locs2=locs(nlocs2)
pks1=pks(nlocs1) % values of 1st group of peaks
pks2=pks(nlocs2)
[max_pks1,n_max_pks1]=max(pks1) % what value has each peak
[max_pks2,n_max_pks2]=max(pks2)
pks1(n_max_pks1)
pks2(n_max_pks2)
nlocs1(n_max_pks1) % peaks locs in string locator returned by findpeaks
nlocs2(n_max_pks2)
loc_peak1=locs(nlocs1(n_max_pks1)) % peaks locations in V and |s11|
loc_peak2=locs(nlocs2(n_max_pks2))
[n1_pk1,n2_pk1]=ind2sub(size(V),loc_peak1)
640513 is pointer equivalent to [257 257]
[n1_pk2,n2_pk2]=ind2sub(size(V),loc_peak2)
4687369 is pointer equivalent to [495 1875]
check on V surface
hold all;plot3(n2_pk1,n1_pk1,V(n2_pk1,n1_pk1)+2,'go',...
'MarkerEdgeColor','g',…
'MarkerFaceColor','g',…
'MarkerSize',10)
hold all;plot3(n2_pk2,n1_pk2,V(n2_pk2,n1_pk2)+2,'ro',...
'MarkerEdgeColor','g',…
'MarkerFaceColor','g',…
'MarkerSize',10)
= 10.188490651197503
= 1.813192017180561
= 14
= 30
= 640513
= 4687369
n1_pk1 =
257
n2_pk1 =
257
n1_pk2 =
495
n2_pk2 =
1875
campos(1.0e+04*[-0.8847438 -2.2297478 0.0012768])
D1=drange;D2=D1;
D11=D1(n1_pk1)
D12=D1(n1_pk2)
D21=D2(n2_pk1)
D22=D2(n2_pk2)
putting all stub lengths in same matrix
D=[D11 D12;D21 D22]
D11 = 0.051200000000000
D12 = 0.098800000000000
D21 = 0.051200000000000
D22 = 0.374800000000000
D =
0.051200000000000 0.098800000000000
0.051200000000000 0.374800000000000
Frequency response directly connecting component impedances
c0=2.998e8;
stubs physical lengths
L=D*c0/f0
L3=D3*c0/f0
f0=2e9;
df=1e6;
defining frequency band to sweep with f1 f2 start stop frequencies
f1=1e9;f2=3e9; f=[f1:df:f2];
frel=linspace(f1/f0,f2/f0,numel(f));
connecting impedances
Zin_stub1=Z0*1j*tan(2*pi*frel*f0/c0*L(1,1))
Zin2=(Zin_stub1.^-1+ZL.^-1).^-1;
Zin3=Z0*(Zin2+1j*Z0*tan(2*pi*frel*f0/c0*L3))./…
(Z0+1j*Zin2.*tan(2*pi*frel*f0/c0*L3)) ;
Zin_stub2=Z0*1j*tan(2*pi*frel*f0/c0*L(2,1));
Zin4=(Zin_stub2.^-1+Zin3.^-1).^-1
s11_1=(Zin4-Z0)./(Zin4+Z0)
Zin_stub1=Z0*1j*tan(2*pi*frel*f0/c0*L(1,2))
Zin2=(Zin_stub1.^-1+ZL.^-1).^-1;
Zin3=Z0*(Zin2+1j*Z0*tan(2*pi*frel*f0/c0*L3))./…
(Z0+1j*Zin2.*tan(2*pi*frel*f0/c0*L3)) ;
Zin_stub2=Z0*1j*tan(2*pi*frel*f0/c0*L(2,2));
Zin4=(Zin_stub2.^-1+Zin3.^-1).^-1
s11_2=(Zin4-Z0)./(Zin4+Z0)
hf3=figure(3); %ax3=hf3.CurrentAxes
plot(frel,abs(s11_1),frel,abs(s11_2));grid on;
xlabel('f/f0')
title('|s11(f)|')
legend({'D(1,1) D(2,1)','D(1,2) D(2,2)'},… 'location','northeastoutside')