Help with loop (for?)

Hello Matlab community ! I have made the following program :
Angle=rand(5,3);
%--------------------------Finger 1--------------------------
Angle(1,1)= 90;
Angle(1,2)=-45;
Angle(1,3)=-90;
kinimatiko(Angle(1,1),Angle(1,2),Angle(1,3))
%-------------------------------------------------------------
%--------------------------Finger 2--------------------------
Angle(2,1)= 80;
Angle(2,2)=-35;
Angle(2,3)=-80;
kinimatiko(Angle(2,1),Angle(2,2),Angle(2,3)) %-------------------------------------------------------------
etc..
kinimatiko is a function i use in this program after i have already ran it.I use it to move the fingers for my project(forward kinematics).
What i do is , i make a (5,3) table and i give the angle for each joint of the finger as you can see above.
What i want to do is , instead of repeating the same thing 5 times ,do it one time but with a loop (for ? ) So i was trying to use the loop "for" but i failed. What i made is this :
Angle=rand(i,j)
for i=1:1:5;
i=i'
for j=1:1:3;
j=j'
end
end
I really need some help please !
Thanks a lot in advance :)

 採用された回答

Honglei Chen
Honglei Chen 2012 年 1 月 31 日

0 投票

I don't quite understand what you do with i=i', but I think what you want is
Angle = rand(5,3);
for m = 1:5
kinimatiko(Angle(m,1),Angle(m,2),Angle(m,3));
end

3 件のコメント

Nikolaos
Nikolaos 2012 年 1 月 31 日
Hello and thanks for your answer!
Well yeah that did work indeed. But it is kinda the same again
I mean it goes like this :
Angle = rand(5,3);
Angle(1,1)= 90;
Angle(1,2)=-45;
Angle(1,3)=-90;
.
.
.
Angle(5,1)=-50;
Angle(5,2)=55;
Angle(5,3)=50;
for m = 1:5
kinimatiko(Angle(m,1),Angle(m,2),Angle(m,3));
end
Or is there anything else i need to change ?
Is there any chance i will be able to use the
Angle(m,1)=-50;
Angle(m,2)=55;
Angle(m,3)=50;
just once in the program and just changing the angle for each finger ?
Honglei Chen
Honglei Chen 2012 年 1 月 31 日
why not just do
Angle = [90 -45 -90; ... ; -50 55 50].'
Nikolaos
Nikolaos 2012 年 1 月 31 日
Thanks a lot ! :)

サインインしてコメントする。

その他の回答 (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