how can i add each element in array to a fixed matrix
2 views (last 30 days)
Show older comments
I have a complex array A(3x1) and Iwant to add each element to each of entry of the complex matrix M (4x4), but without changing the size of the original matrix M(4x4):
A = [1+1i;2+2i;3+3i];
M= [1+1i 2+2i 3+3i 4+4i;2+2i 3+3i 4+4i 3+3i;5+5i 2+2i 3+3i 1+1i;3+3i 4+3i 2+1i 4+2i];
how can i do it ? thanks in advance
2 Comments
Jan
on 12 Apr 2013
While the complexity of the values does not matter for the method, it is not clear what you expect as output.
Answers (1)
Andrei Bobrov
on 12 Apr 2013
Edited: Andrei Bobrov
on 12 Apr 2013
out = bsxfun(@plus,M,reshape(A,1,1,[]));
M0 = num2cell(out,[1 2]);
[M1,M2,M3] = M0{:};
0 Comments
See Also
Categories
Find more on Multidimensional 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!