Matrix dimensions must agree

조회 수: 2 (최근 30일)
soko loko
soko loko 2014년 8월 31일
댓글: soko loko 2014년 8월 31일
Hi:
Im trying to develop a generalized jacobian for a free space manipulator. Im using the following code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
phi0 = 0.25*pi; phi1 = 0.25*pi; phi2 = 0.25*pi;
m0 = 1100; m1 = 25; m2 = 25;
a1 = 0.5; a2 = 0.5;
b0 = 0.5; b1 = 0.5; b2 = 0.5;
l0 = 0.5; l1 = 0.5; l2 = 0.5;
w = m0 + m1 + m2;
M0 = m0*(m1+m2)/w; M1 = m0*m2/w; M2 = (m0 + m1)*m2/w;
I0 = [(1100*2)/12 0 0;0 (1100*2)/12 0;0 0 (1100*2)/12]; I1 = [0.0267 0 0;0 0.3467 0;0 0 2.5]; I2 = [0.0267 0 0;0 0.3467 0;0 0 2.5];
h0 = I0 + M0*b0^2; h1 = I1 + M0*a1^2 + M2*b1^2 + 2*M1*a1*b1; h2 = I2 + M2*a2^2;
hc1 = (M0*b0*a1 + M1*b0*b1)*cos(phi1); hc2 = (M1*a1*a2 + M2*b1*a2)*cos(phi2); hc3 = M1*b0*a2*cos(phi1 + phi2);
Ka = (m0*b0/l0)/w; Kb = (m0 + m1*b1/l1)/w; Kc = (m0 + m1 + m2*b2/l2)/w;
IM1 = h1 + h2 + hc1+ 2*hc2 + hc3; IM2 = h2 + hc2 + hc3; IS = h0 + h1 + h2 + 2*hc1 + 2*hc2 + 2*hc3;
s0 = sin(phi0); s1 = sin(phi0 + phi1); s2 = sin(phi0 + phi1 + phi2); c0 = cos(phi0); c1 = cos(phi0 + phi1); c2 = cos(phi0 + phi1 + phi2);
JM = [-l1*s1 -l2*s2; l1*c1 l2*c2]*[Kb 0; Kc Kc] - [-Ka*l0*s0 - Kb*l1*s1 - Kc*l2*s2; Ka*l0*c0 + Kb*l1*c1 + Kc*l2*c2]*[IM1/IS IM2/IS]; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
As per the consulted documentation, the term [IM1/IS IM2/IS] should be a 2X1 matrix so it result in a 2X2 matrix when multiplied by the term [-Ka*l0*s0 - Kb*l1*s1 - Kc*l2*s2; Ka*l0*c0 + Kb*l1*c1 + Kc*l2*c2] that is a 1X2 matrix.
What does the "/" simbol means in order to get such result???
Thank you in advance!
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2014년 8월 31일
Soko - if you step through the code, you will notice that IM1 and *IM2 are 3x3 matrices. As are, IM1/IS IM2/IS. The result, [IM1/IS IM2/IS], is a 3x6 matrix. Hence the error. What documentation are you consulting?
soko loko
soko loko 2014년 8월 31일
Im consulting this article: Resolved Motion Rate Control of Space Manipulators with Generalized Jacobian Matrix, page 6. I noticed that before so I was thinking the "/" was supposed to be a special symbol (different than division)

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

답변 (1개)

Star Strider
Star Strider 2014년 8월 31일
The ‘/’ symbol in that context is ‘matrix right divide’ or mrdivide.
  댓글 수: 2
soko loko
soko loko 2014년 8월 31일
mrdivide is the same as "/". Problem persists.
Star Strider
Star Strider 2014년 8월 31일
If you break JM apart, the problem shows itself:
JM1 = [-l1*s1 -l2*s2; l1*c1 l2*c2]*[Kb 0; Kc Kc];%
JM2 = - [-Ka*l0*s0 - Kb*l1*s1 - Kc*l2*s2; Ka*l0*c0 + Kb*l1*c1 + Kc*l2*c2];
JM3 = [IM1/IS IM2/IS];
JM1 is (2x2), JM2 is (2x1) but JM3 is (3x6). Also, IM1, IM2, and IS are all (3x3).
I’ll let you sort out whatever the problem is with IM1, IM2, and IS being (3x3) rather than (2x2) that you want them to be.

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

카테고리

Help CenterFile Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by