Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Unable to get all the points graphed.

1 回表示 (過去 30 日間)
c
c 2011 年 11 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have written the code below and for some reason it is only plotting the last values of n1 and beta. What am I doing wrong? I have even tried moving the plot code outside of the For Loop and that did not change anything.
Thank you for your help!
alpha=asind(.707107);
theta=asind(.34202);
n2=1.35;
na=1;
for n1=1.0:0.01:1.4
a=sin(alpha)/(n1);
beta1=asind(a);
alpha1=beta1+theta;
b=(n1*sind(alpha1))/n2;
beta2=asind(b);
alpha2=beta2-theta;
c=(n2*sind(alpha2))/na;
beta=asind(c);
plot(n1,beta)
end

回答 (2 件)

Steven
Steven 2011 年 11 月 3 日
you miss an hold on:
plot(n1,beta); hold on;
will be better.

Kelly Kearney
Kelly Kearney 2011 年 11 月 3 日
The plot command clears an axis unless you issue a
hold on
command. In your case, though, the loop is unnecessary:
alpha=asind(.707107);
theta=asind(.34202);
n2=1.35;
na=1;
n1=1.0:0.01:1.4
a=sin(alpha)./(n1);
beta1=asind(a);
alpha1=beta1+theta;
b=(n1.*sind(alpha1))./n2;
beta2=asind(b);
alpha2=beta2-theta;
c=(n2.*sind(alpha2))./na;
beta=asind(c);
plot(n1,beta)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by