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 Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by