필터 지우기
필터 지우기

how can i fix this error?

조회 수: 1 (최근 30일)
Emily Gobreski
Emily Gobreski 2016년 6월 12일
댓글: Guillaume 2016년 6월 12일
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.
  댓글 수: 3
Emily Gobreski
Emily Gobreski 2016년 6월 12일
I am confused. I entered it using the formatting code.
Guillaume
Guillaume 2016년 6월 12일
I think what Muhammad meant is your write your long matrix on more than one row as it's difficult to read long lines on the forum.
I've reformated your post so it's easier to see your matrix. Kudos for using the formatting tools.

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

채택된 답변

Guillaume
Guillaume 2016년 6월 12일
Presumably one of R, theta, sign (!), u, y, or c is not scalar but a matrix or column vector. You can't horizontally concatenate scalars with matrices or column vector, hence the error.
Find out which variable is the culprit on why it's not scalar (or why you're using a non scalar variable in your expression).
Also, I strongly recommend changing the name of the sign variable. sign is already a function in matlab which you won't be able to use if you've got a variable of the same name.
  댓글 수: 1
Emily Gobreski
Emily Gobreski 2016년 6월 12일
Wonderful, thank you so much!

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

추가 답변 (1개)

Muhammad Usman Saleem
Muhammad Usman Saleem 2016년 6월 12일
One of the rows does not have the same number of columns as the other.
One of the ways this could happen is if one of the elements is empty when the others are not.
  댓글 수: 1
Guillaume
Guillaume 2016년 6월 12일
Actually, if the problem was with the number of elements per row, the error would have been "Error using vertcat".

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

카테고리

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