Info
この質問は閉じられています。 編集または回答するには再度開いてください。
how to add matrices with one dimension same and other dimension different such that each element is added to every other element?
1 回表示 (過去 30 日間)
古いコメントを表示
I have matrices A=2x2 B=2x4 C=2x2 I want result in a matrix D=2x16 for example
A=[1 3;
2 4]
B=[3 2 4 2;
4 3 6 3]
C=[4 5;
7 5]
D=[(1+3+4) (1+3+5) (1+2+4) (1+2+5) (1+4+4) (1+4+5) (1+2+4) (1+2+5) (3+3+4) (3+3+5) (3+2+4) (3+2+5) (3+4+4) (3+4+5) (3+2+4) (3+2+5);
(2+4+7) (2+4+5) (2+3+7) (2+3+5) (2+6+7) (2+6+5) (2+3+7) (2+3+5) (3+4+7) (3+4+5) (3+3+7) (3+3+5) (3+6+7) (3+6+5) (3+3+7) (3+3+5)]
means that row wise elements are added in resultant. I have a code in which A=2x1 but I can understand how to mold it according to A=2x2 the code is given below
[rows,col_B]=size(B);
[~,col_C]=size(C);
result=zeros(rows,col_B*col_C);
for i=1:col_B
for j=1:col_C
result(:,(i-1)*col_C+j)=A+B(:,i)+C(:,j);
end
end
can anybody tell me the syntax for the output RESULT in this code?
0 件のコメント
回答 (0 件)
この質問は閉じられています。
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!