Help with Function please !

Hello Matlab community!
I need your help for one more time ! :)
Well i have made a program for the forward kinematics of one finger. That program has a function which is ... function kin(q1,q2,q3,t) These (q1,q2,q3) are the angles of the joints for the finger. I want to do that for the rest of the fingers but i don't want to make the exact same program for each of the fingers. I want to just do that from one program. What i have in mind is , if it is q1_1, q1_2, q1_3 it is for the first finger , q2_1, q2_2, q2_3 is for the second finger etc.
Can you please help me with this ? Thanks a lot in advance Nick

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 12월 29일

0 개 추천

I suggest you make a 5x3 matrix, for example,
FingerAngle=rand(5,3);
Then call the function for the first finger
kin(FingerAngle(1,1),FingerAngle(1,2),FingerAngle(1,3))
For the second finger, it will be
kin(FingerAngle(2,1),FingerAngle(2,2),FingerAngle(2,3))
Or a little bit advanced, use cell array
FingerAngle=num2cell(rand(5,3));
% for the first finger
kin(FingerAngle{1,:})
% for the second finger
kin(FingerAngle{2,:})

댓글 수: 3

Nikolaos
Nikolaos 2011년 12월 29일
As i am kinda new to Matlab i got stuck again though. So the program will go like this
FingerAngle =rand(5,3);
kin(FingerAngle(1,1),FingerAngle(1,2),FingerAngle(1,3))
kin(FingerAngle(2,1),FingerAngle(2,2),FingerAngle(2,3))
kin(FingerAngle(3,1),FingerAngle(3,2),FingerAngle(3,3))
kin(FingerAngle(4,1),FingerAngle(4,2),FingerAngle(4,3))
kin(FingerAngle(5,1),FingerAngle(5,2),FingerAngle(5,3))
I wrote that and i saw all the fingers on a figure (as i have it in my kinematic program) The thing that i got confused is , where exactly do i put the number for each of the angles ?As it was before the q1,q2,q3 for each finger
Fangjun Jiang
Fangjun Jiang 2011년 12월 29일
If you want to set the angle value as you want, you can do
FingerAngle(1,1)=pi/4;
FingerAngle(1,3)=pi/6;
FingerAngle(3,2)=pi/5;
...
Nikolaos
Nikolaos 2011년 12월 30일
I love you !
Thank you again :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 12월 29일

0 개 추천

Use a matrix.
Q = zeros(5,3);
And store in the corresponding ij indices of Q.

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by