I am not getting the exact reactance part value j1.8 (mentioned in BOOK) using my code , I am getting zero for my reactance part code, Can anybody help me out?
68 views (last 30 days)
Show older comments
SSWH2
on 13 Nov 2024 at 6:29
Commented: Epsilon
on 18 Nov 2024 at 1:57
I am here mentioning my code , using this code my input imedance should be 233.9_j1.8 ohm, I am getting 234 ohm for the real part but my reactance part of the input impedance is zero. Here, i am attaching the equations which I am using in my code for imedance calculation and I am also providing the code output plot from the book here. I am mainly using equation 25 to get output. I need exactly that figure value in output plot. I am getting exactly same for the real part by my reactance part is showing 0 value.Kindly fix my code so that I can get exact value for the reactance part.
%Parameters TE10
c= 299792458;
m=1;
n=0;
h= 0.0795e-2;
dm=2;
dn=1;
eps0= 8.85418782e-12;
epsR= 2.32;
eps= eps0*epsR;
a= 10e-2;
b= 1.5e-2;
theta1 =2e-2/(a+h);
z_p =-1.5e-2;
phi_p =1e-2/(a+h);
w= 5e-3;
Qf= 112.4;
del_eff= 1/Qf;
fr=[2349:1:2549]*1e+6;
fmn=c/(2*sqrt(epsR))*sqrt((m/(2*(a+h)*theta1)^2)+(n/(2*b))^2);
%fmn= 2449e+6;
befn= sin(m*pi*w/(4*a*theta1))/(m*pi*w/(4*a*theta1));
%Z= ((h*dm*dn)/(8*pi*a*b*theta1))*((cos (n*pi*z_p)/(2*b))^2)*((cos(m*pi*phi_p)/(2*theta1))^2)*((bessel(j0,m*pi*w)/(4*a*theta1)).^2)* ((del_eff^3)-i(freq)(freq^2-fmn^2))/(del_eff^4+)
Zin= h*dm*dn/(8*pi*eps*a*b*theta1)*cos(n*pi*z_p/(2*b))^2*cos(m*pi*phi_p/(2*theta1))^2*befn^2.*(del_eff*fr.^3-1i*fr.*(fr.^2-fmn^2))./(del_eff^2*fr.^4+(fr.^2-fmn^2).^2)
figure(1)
plot(fr*1e-6,real(Zin),'b','LineWidth',3);
hold on
plot(fr*1e-6,imag(Zin),'r','LineWidth',3);
set(gcf,'color',[1 1 1]);
set(gca,'fontsize',18);
xlabel('freq [MHz]')
ylabel('R and X [ohm]');
xlim([2349 2549]);
%ylim([1480 1560]);
legend('R','X');
for k=1:length(fr)
if(fr(k)==fmn) % replace fmn with any desired frequency to get the imput impedance at this freq.
Zin_res=complex(real(Zin(k))+imag(Zin(k)));
end
end
k
Zin_res
0 Comments
Accepted Answer
Epsilon
on 13 Nov 2024 at 7:15
Edited: Epsilon
on 13 Nov 2024 at 7:22
Hi,
The 'Zin_res' is not calculated properly as the validation "if(fr(k)==fmn);" fails due to the mismatch in exact values. To get the input impedance at the resonant frequency find the index at which the difference between the current and the resonant frequency is minimum. Then index into the array.
Modified code:
%Parameters TE10
c= 299792458;
m=1;
n=0;
h= 0.0795e-2;
dm=2;
dn=1;
eps0= 8.85418782e-12;
epsR= 2.32;
eps= eps0*epsR;
a= 10e-2;
b= 1.5e-2;
theta1 =2e-2/(a+h);
z_p =-1.5e-2;
phi_p =1e-2/(a+h);
w= 5e-3;
Qf= 112.4;
del_eff= 1/Qf;
fr=[2349:1:2549]*1e+6;
fmn=c/(2*sqrt(epsR))*sqrt((m/(2*(a+h)*theta1)^2)+(n/(2*b))^2);
%fmn= 2449e+6;
befn= sin(m*pi*w/(4*a*theta1))/(m*pi*w/(4*a*theta1));
%Z= ((h*dm*dn)/(8*pi*a*b*theta1))*((cos (n*pi*z_p)/(2*b))^2)*((cos(m*pi*phi_p)/(2*theta1))^2)*((bessel(j0,m*pi*w)/(4*a*theta1)).^2)* ((del_eff^3)-i(freq)(freq^2-fmn^2))/(del_eff^4+)
Zin= h*dm*dn/(8*pi*eps*a*b*theta1)*cos(n*pi*z_p/(2*b))^2*cos(m*pi*phi_p/(2*theta1))^2*befn^2.*(del_eff*fr.^3-1i*fr.*(fr.^2-fmn^2))./(del_eff^2*fr.^4+(fr.^2-fmn^2).^2);
figure(1)
plot(fr*1e-6,real(Zin),'b','LineWidth',3);
hold on
plot(fr*1e-6,imag(Zin),'r','LineWidth',3);
set(gcf,'color',[1 1 1]);
set(gca,'fontsize',18);
xlabel('freq [MHz]')
ylabel('R and X [ohm]');
xlim([2349 2549]);
%ylim([1480 1560]);
legend('R','X');
% Find the index of the frequency closest to the resonant frequency fmn
[~, resonant_index] = min(abs(fr - fmn));
% Get the input impedance at the resonant frequency
Zin_res = Zin(resonant_index);
% Display the resonant frequency and the corresponding impedance
disp(['Resonant frequency index: ', num2str(resonant_index)]);
disp(['Resonant frequency (Hz): ', num2str(fr(resonant_index))]);
disp(['Zin at resonant frequency: ', num2str(Zin_res)]);
Glad to help!
10 Comments
More Answers (0)
See Also
Categories
Find more on Custom Geometry and PCB Fabrication in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!