Matrix dimensions must agree
4 views (last 30 days)
Show older comments
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 Comments
Geoff Hayes
on 31 Aug 2014
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?
Answers (1)
Star Strider
on 31 Aug 2014
2 Comments
Star Strider
on 31 Aug 2014
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.
See Also
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!