Info

此问题已关闭。 请重新打开它进行编辑或回答。

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 次查看(过去 30 天)
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));

回答(1 个)

Star Strider
Star Strider 2016-10-14
Your ‘x’ vector is a single point, ‘xd1’, because the step size is larger than the terminating value. Use the linspace function to create ‘x’. You also have to use the hold function and semilogy to plot and see both vectors:
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; % <— REPLACE WITH ‘linspace’
x = linspace(xd1, xd2, 10); % 10-Element Vector
k = sqrt(es)./(4*pi*q*sqrt(l)*sqrt(a)*(2.2e5)*x.^1.5); % <— DO ELEMENT-WISE DIVISION
figure(1)
semilogy(x,k)
xlabel('xd');
ylabel('nd');
hold on % <— ADD ‘hold’
plot(x,log10(k));
hold off % <— ADD ‘hold off’

此问题已关闭。

标签

尚未输入任何标签。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by