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

2 次查看(过去 30 天)
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 个评论
Adam
Adam 2016-6-13
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.

请先登录,再进行评论。

采纳的回答

the cyclist
the cyclist 2016-6-13
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by