how can i add each element in array to a fixed matrix

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

Jan
Jan 2013년 4월 12일
While the complexity of the values does not matter for the method, it is not clear what you expect as output.
Hi Jan, Actually I want each element in the array A(3x1) to added to all the element in the matrix, therefore the result should be 3 new matrix for each element. for example :
A(1+1i) + M (4x4) = M1(4x4) % 1 new matrix
A(2+2i) + M (4x4) = M2(4x4) % 2 new matrix
A(3+3i) + M (4x4) = M3(4x4) % 3 new matrix
BR
Arjan

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

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2013년 4월 12일
편집: Andrei Bobrov 2013년 4월 12일
out = bsxfun(@plus,M,reshape(A,1,1,[]));
M0 = num2cell(out,[1 2]);
[M1,M2,M3] = M0{:};

카테고리

도움말 센터File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

질문:

2013년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by