please help in for loop :(

2 次查看(过去 30 天)
Mech
Mech 2014-6-6
评论: Mech 2014-6-7
for m=1:2
rx=1+2*l*sin(m*b)*m
ry=1+2*l*cos(m*b)*m;
end
plot([1 rx 10],[1 ry 10]);
where l is given I need two value for rx and also for ry I mean that the result should be like this :
rx=0+2*l*sin(1*b)*1
ry=0+2*l*cos(1*b)*1;
rx=0+2*l*sin(2*b)*2
ry=0+2*l*cos(2*b)*2;
  2 个评论
John D'Errico
John D'Errico 2014-6-6
Huh? Totally unclear as to what you are trying to do.
Image Analyst
Image Analyst 2014-6-6
It's not clear if the first term should be 0, like after the loop, or 1, like you have it inside the loop. My answer below assumes 1.

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2014-6-6
Get rid of the for loop. Just do this:
m=1:2
rx=1+2*l*sin(m*b)*m
ry=1+2*l*cos(m*b)*m;
  5 个评论
Image Analyst
Image Analyst 2014-6-7
It means element by element multiplication, instead of a matrix multiplication.
Mech
Mech 2014-6-7
thank you Analyst ;)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile 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