I want to plot graph when alpha =2.8 or 2.9, but the graph not appear.
1 view (last 30 days)
Show older comments
mohd akmal masud
on 23 Mar 2023
Commented: mohd akmal masud
on 27 Mar 2023
Dear Sir,
I want to plot the graph for alpha=2.8 or 2.9. But the graph not appear.
Anyone can help me
clc
clear all
close all
theetasd = -90:.01:90; %Defining X axis vector
theetaid = 30; %Variable Theeta i in degrees
phisd = 90;
theetai = theetaid * pi/180; %Variable Theeta i in radian
theetas = theetasd * pi/180; %Variable Theeta s in radian
phis = phisd * pi/180;
%constants
ay =1 ;
az= 1;
H0=1;
n=1;
eita=1;
y=1;
z=1;
%Parameters
lembda = 0.8;
beeta = 8;
a = 5*lembda;
b = 5*lembda;
d=1;
syms r
alpha=2.8
part1=-(j.*eita.*a.*b.*H0.*((pi./2).^0.5).*(beeta.*d.*cos(theetai)).^abs((3-alpha)/2).* besselh(abs((3-alpha)/2),1,(beeta.*d.*cos(theetai))).* beeta.*(2.^(3-alpha)).*((pi).^0.5)./2);
part2=(2.*(pi).*(gamma((alpha)./2)));
C=(part1)/(part2);
Ei = n.*H0.*((pi./2).^0.5).*((ay.*cos(theetai))+(az.*sin(theetai))).*(beeta.*z.*cos(theetai)).^abs((3-alpha)/2).*(exp(-j.*beeta.*((y.*sin(theetai))))).*besselh(abs((3-alpha)/2),1,(beeta.*d.*cos(theetai)));
%Equation for Es-Phi
p = beeta.*a./2.*(sin(theetas).*cos(phis));
q = beeta.*b./2.*((sin(phis).*sin(theetas))-sin(theetai));
Esth = (C.*exp(-j.*beeta.*r)./r.^(alpha-2)).*((cos(theetas)).*sin(phis).*(((sin(p)./(p)).*(sin(q))./(q))));
Esphi = (C.*exp(-j.*beeta.*r)./r.^(alpha-2)).*(cos(phis).*(((sin(p))./(p)).*(sin(q))./(q)));
%Equation for Es
Es=sqrt((Esth).^2+(Esphi).^2);
%Equation for Sigma
sigma = limit((4.*pi.*r.^2).*abs((Esth).^2/(Ei).^2), r, inf);
sigma = 5*log( sigma);
plot(theetasd,sigma,'black--')
1 Comment
the cyclist
on 23 Mar 2023
I suggest that you learn to use the debugging tools that MATLAB provides. You can set a breakpoint at the plotting line, and see what is going on.
In this case, I can see that every value of sigma is Inf. I did not trace back why that happens.
Accepted Answer
Sandeep
on 27 Mar 2023
Hi mohd akmal masud,
It is my understanding that you are facing an issue in plotting a Graph simulating Electromagnetic wave propagation. The reason is that the sigma variable is a scalar value and cannot be plotted against a vector. In the last line of the code, sigma is assigned a scalar value by taking the logarithm of a limit expression. Therefore, when plot(theetasd, sigma, 'black--') is executed, MATLAB throws an error because it is not possible to plot a scalar value against a vector.
To fix this, you could modify the code to store the conductivity values for each value of theetasd in a vector, rather than just a single scalar value. You could initialize an empty vector sigma_vals and then assign the calculated sigma value to sigma_vals(i) at each iteration of the loop. Then, you can plot the resulting sigma_vals vector against theetasd.
For more insite on Plot function refer:
2 Comments
Dyuman Joshi
on 27 Mar 2023
sigma is not a scalar nor does the any command throw an error.
The sizes of theetasd and sigma are compatible for plotting a graph as well.
theetasd = -90:.01:90; %Defining X axis vector
theetaid = 30; %Variable Theeta i in degrees
phisd = 90;
theetai = theetaid * pi/180; %Variable Theeta i in radian
theetas = theetasd * pi/180; %Variable Theeta s in radian
phis = phisd * pi/180;
%constants
ay =1 ;
az= 1;
H0=1;
n=1;
eita=1;
y=1;
z=1;
%Parameters
lembda = 0.8;
beeta = 8;
a = 5*lembda;
b = 5*lembda;
d=1;
syms r
alpha=2.8;
part1=-(j.*eita.*a.*b.*H0.*((pi./2).^0.5).*(beeta.*d.*cos(theetai)).^abs((3-alpha)/2).* besselh(abs((3-alpha)/2),1,(beeta.*d.*cos(theetai))).* beeta.*(2.^(3-alpha)).*((pi).^0.5)./2);
part2=(2.*(pi).*(gamma((alpha)./2)));
C=(part1)/(part2);
Ei = n.*H0.*((pi./2).^0.5).*((ay.*cos(theetai))+(az.*sin(theetai))).*(beeta.*z.*cos(theetai)).^abs((3-alpha)/2).*(exp(-j.*beeta.*((y.*sin(theetai))))).*besselh(abs((3-alpha)/2),1,(beeta.*d.*cos(theetai)));
%Equation for Es-Phi
p = beeta.*a./2.*(sin(theetas).*cos(phis));
q = beeta.*b./2.*((sin(phis).*sin(theetas))-sin(theetai));
Esth = (C.*exp(-j.*beeta.*r)./r.^(alpha-2)).*((cos(theetas)).*sin(phis).*(((sin(p)./(p)).*(sin(q))./(q))));
Esphi = (C.*exp(-j.*beeta.*r)./r.^(alpha-2)).*(cos(phis).*(((sin(p))./(p)).*(sin(q))./(q)));
%Equation for Es
Es=sqrt((Esth).^2+(Esphi).^2);
%Equation for Sigma
sigma = limit((4.*pi.*r.^2).*abs((Esth).^2/(Ei).^2), r, inf);
sigma = 5*log( sigma)
size(theetasd)
size(sigma)
plot(theetasd,sigma,'k--')
More Answers (0)
See Also
Categories
Find more on Calculus 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!