my code is running but it didn't display the graph even if it put the x and y value in the axis. here is my code
1 view (last 30 days)
Show older comments
my code is running but it didn't display the graph even if it put the x and y value in the axis. here is my code
a=0.0001; l=0.0003; eo=8.85e-14; er=11.9; es=eo*er; f1 = 550e3; f2 = 1650e3; q=1.6e-19; c1=1/(4*pi*pi*f1*l); c2=1/(4*pi*pi*f2*l); xd1=(a*es)/c1; xd2=(a*es)/c2; n1=sqrt(es)/(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*xd1^1.5); n2=sqrt(es)/(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*xd2^1.5); x =xd1:0.01:xd2; k = sqrt(es)/(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*x.^1.5); figure(1) plot(x,k) xlabel('xd'); ylabel('nd'); plot(x,log10(k)); _ _ |
*# * italic*|__
1 Comment
Josh
on 15 Oct 2016
Since xd1 and xd2 are extremely small numbers, then your step size should be smaller. Change x = xd1:0.01:xd2 to x = xd1:xd1/100:xd2.
Also, you must insert a "." before the division where you define k. Change that line of code to the following: k = sqrt(es)./(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*x.^1.5);
Copy and paste the code below excluding the first and last lines
if true
a=0.0001;
l=0.0003;
eo=8.85e-14;
er=11.9;
es=eo*er;
f1 = 550e3;
f2 = 1650e3;
q=1.6e-19;
c1=1/(4*pi*pi*f1*l);
c2=1/(4*pi*pi*f2*l);
xd1=(a*es)/c1;
xd2=(a*es)/c2;
n1=sqrt(es)./(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*xd1^1.5);
n2=sqrt(es)./(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*xd2^1.5);
x =xd1:xd1/100:xd2;
k = sqrt(es)./(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*x.^1.5);
figure(1)
plot(x,k)
xlabel('xd');
ylabel('nd');
plot(x,log10(k));
end
Answers (1)
Pritesh Shah
on 15 Oct 2016
x is scalar. That is main reason. use linspace command to create different samples between xd1 and xd2.
e.g, linspace(xd1,xd2,100)
a=0.0001; l=0.0003; eo=8.85e-14; er=11.9; es=eo*er; f1 = 550e3; f2 = 1650e3; q=1.6e-19; c1=1/(4*pi*pi*f1*l); c2=1/(4*pi*pi*f2*l); xd1=(a*es)/c1; xd2=(a*es)/c2; n1=sqrt(es)/(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*xd1^1.5); n2=sqrt(es)/(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*xd2^1.5); x =linspace(xd1,xd2,100); k = sqrt(es)./(4.*pi.*q.*sqrt(l).*sqrt(a)*(2.2e5).*x.^1.5); figure(1); plot(x,k); xlabel('xd'); ylabel('nd'); plot(x,log10(k))
0 Comments
See Also
Categories
Find more on Graphics Object Identification 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!