Clear Filters
Clear Filters

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

2 views (last 30 days)
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 Comments
Roger Stafford
Roger Stafford on 12 Jun 2016
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 on 12 Jun 2016
Thank so much for your help. I really appreciate it!

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 12 Jun 2016
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 Comments
Emily Gobreski
Emily Gobreski on 12 Jun 2016
Great! Thank you so much for your help! I really appreciate it.

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!