Clear Filters
Clear Filters

How can I fix error: horzcat dimensions of matrices being concatenated are not consistent?

2 views (last 30 days)
theta=210
sign=(cosd (theta)/abs (cosd (theta)))
u=.8
R=12
c=5
y=18
Id=(.5*Md*R^2)
Mp=75
Mb=30
alpha=0
u=.8
L=6*R
a=[1 0 1 0 0 0 0 0 0 0 0; 0 1 0 1 0 0 0 0 0 0 0; 0 0 -R*sind(theta) R*cosd(theta) 0 0 0 0 0 0 1; 0 0 0 0 1 0 1 0 0 0 0; 0 0 0 0 0 1 0 1 0 0 0; 0 0 0 0 -R*sind(theta) R*cosd(theta) 0 0 0 0 0; 0 0 -1 0 -1 0 0 0 (4*abs(sign)) 0 0; 0 0 0 -1 0 -1 0 0 (-4*u*sign) 0 0; 0 0 -c (3*R) -c (-3*R) 0 0 (-4*(y-c)) 0 0; 0 0 0 0 0 0 0 0 -sign u*sign 0; 0 0 0 0 0 0 0 0 (-u*sign) 1 0]
Error using horzcat Dimensions of matrices being concatenated are not consistent.
  2 Comments
Adam
Adam on 13 Jun 2016
Code seems to work fine for me, depending on what Md actually is. Though since that seems not to be related to the matrix being produced at the end I just put a scalar in for that and also tried a vector. Both ran fine.

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 13 Jun 2016
I added the definition
Md = 1;
to get your code to run, but then it ran to completion for me. Are you sure you pasted in the line that caused the error?
It's hard for me to diagnose an error that I cannot replicated, but I would suggest checking the sizes of the intermediate variables, to make sure they are what you expect.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!