Inner matrix dimensions must agree.
Show older comments
I am trying to solve the the equation below and keep getting the error that inner matrix dimensions don't agree. I've been looking at this for awhile and can't figure it out. K1 = 4x4 matrix, W = 4x4 matrix, TD = 4x3 matrix, tau = 3x1 matrix.
u2 = inv(K1)*Winv*TD*inv(TD'*Winv*TD)*tau;
3 Comments
David Goodmanson
on 16 Jun 2017
Edited: David Goodmanson
on 16 Jun 2017
Hi m13, Assuming Winv is the obvious thing and is 4x4, this seems to work. Are your matrix dimensions perhaps not what you think they are?
m13
on 16 Jun 2017
David Goodmanson
on 17 Jun 2017
I don't have simulink but no doubt someone who does will weigh in.
Answers (1)
John D'Errico
on 16 Jun 2017
NEVER ASSUME ANYTHING. Never. When you have a problem like this, test those assumptions. Verify your facts. Because the fact is, MATLAB is not a liar. It tells the truth. If it tells you there is a matrix dimension mismatch, then that is because there is one.
whos K1 Winv TD tau
You have told us the shape of those variables. But not all of them. You told us that W is 4x4. Should we just assume that means the variable Winv is also 4x4?
If you are running this inside a function, verify the size of those matrices INSIDE the function. Why? Because people screw up. They change things without realizing they did. They overwrite variables with ones of a different size.
2 Comments
m13
on 16 Jun 2017
John D'Errico
on 17 Jun 2017
I am in the same place as David, lacking simulink, I can't help you in that respect. The fact is your arrays do not conform in size for multiplication. So you need to track that down.
Categories
Find more on Simulink in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!