I am having trouble adding [a]+[b].

조회 수: 2 (최근 30일)
Emily Gobreski
Emily Gobreski 2016년 6월 12일
댓글: Emily Gobreski 2016년 6월 12일
theta=30
Sign=(cosd (theta)/abs (cosd (theta)))
U=.8
R=12
C=5
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 (-u*sign) 1 0]
b=[Ax; Ay; Bx; By;Cx; Cy; Dx; Dy; NB; Nc; T]
a+b=
  댓글 수: 4
Roger Stafford
Roger Stafford 2016년 6월 12일
If the quantities Ax, Ay, Bx, etc. are each scalar numbers, the most serious problem you have is that the two arrays you are attempting to add have different sizes. The ‘a’ array is of size 10-by-11 and the ‘b’ array would be of size 11-by-1. You need to figure your way out of that problem - what are you adding to what? If you do repmat(b,1,10).’, then you could add them (note the transpose operator.) Instead of that you could use the ‘bsxfun’ along with a transpose.
Emily Gobreski
Emily Gobreski 2016년 6월 12일
Thank so much for your help. I really appreciate it!

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

채택된 답변

Star Strider
Star Strider 2016년 6월 12일
MATLAB is case-sensitive, so sign~=Sign and so for the rest. I corrected as many of those as I could find. We also don’t have ‘y’:
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 (-U*Sign) 1 0];
Supply ‘y’ and that assignment may work. I don’t know what you’re doing with ‘b’, and we don’t have any of its elements, so I don’t know if you can do the addition.
  댓글 수: 2
Emily Gobreski
Emily Gobreski 2016년 6월 12일
Great! Thank you so much for your help! I really appreciate it.
Star Strider
Star Strider 2016년 6월 12일
My pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by