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

2 次查看(过去 30 天)
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by