for loop plotting problem

i cannot seem to get my plot to work, i am trying to plot(x,z) the for loop final results (a list of x and z values)
i am not sure as to how to store the x,z values in an array or vector form.
a=0.551;
k=1.889;
e1=0.0222;
n1=1;
%t=0.349;
nn=(2*pi()/360);
for theta=0:nn:(2*pi())
theta1=(atan((a*sin(theta))/(a*cos(theta)-a)))+pi();
theta2=(atan((a*sin(theta))/(a*cos(theta)-a*e1)))+n1*pi();
r1=sqrt((a*cos(theta)-a)^2+(a^2*sin(theta)*sin(theta)));
r2=sqrt((a*cos(theta)-a*e1)^2+(a^2*sin(theta)*sin(theta)));
x=((r1^k)/(r2^(k-1)))*(cos(k*theta1)*cos(k-1)*theta2+sin(k*theta1)*sin(k-1)*theta2)
z=((r1^k)/(r2^(k-1)))*(sin(k*theta1)*cos(k-1)*theta2-cos(k*theta1)*sin(k-1)*theta2);
plot(x,z)
end

 採用された回答

Walter Roberson
Walter Roberson 2013 年 2 月 19 日

1 投票

thetavals = 0:nn:(2*pi());
for thetaidx = 1 : length(thetavals);
theta = thetavals(thetaidx);
[...]
x(thetaidx) = ....
z(thetaidx) = ....
end
plot(x, z);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by