Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

please help in for loop :(

Asked by Mech

Mech

on 6 Jun 2014
Latest activity Commented on by Mech

Mech

on 7 Jun 2014
Accepted Answer by Image Analyst

Image Analyst

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 Comments

John D'Errico

John D'Errico

on 6 Jun 2014

Huh? Totally unclear as to what you are trying to do.

Image Analyst

Image Analyst

on 6 Jun 2014

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.

Mech

Mech

Tags

Products

No products are associated with this question.

1 Answer

Answer by Image Analyst

Image Analyst

on 6 Jun 2014
Accepted answer

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 Comments

Mech

Mech

on 7 Jun 2014

thanks alot roger its work but what th meaning of dot in this place m is matrix, by adding dot what happen ?

Image Analyst

Image Analyst

on 7 Jun 2014

It means element by element multiplication, instead of a matrix multiplication.

Mech

Mech

on 7 Jun 2014

thank you Analyst ;)

Image Analyst

Image Analyst

Contact us