array multiplication and addition
2 ビュー (過去 30 日間)
古いコメントを表示
Dear sir/ma'am
I have a mattrix array, h=1*16 cells each cell contains N*N values. now also I have x= 1*4 cells each contains N*1 value. I want new matrix y=1*4 cells each contains N*1. I have written the matlab code like that
y{1,1}=h{1,1}*x{1,1}+h{1,2}*x{1,2}+h{1,3}*x{1,3}+h{1,4}*x{1,4}
y{1,2}=h{1,5}*x{1,1}+h{1,6}*x{1,2}+h{1,7}*x{1,3}+h{1,8}*x{1,4}
y{1,3}=h{1,9}*x{1,1}+h{1,10}*x{1,2}+h{1,11}*x{1,3}+h{1,12}*x{1,4}
y{1,4}=h{1,13}*x{1,1}+h{1,14}*x{1,2}+h{1,15}*x{1,3}+h{1,16}*x{1,4}
But I want a generic matlab code for this implementation such that I can operate any value of h,x,y cell matrix and reach the same result as above description.
Thank you.
0 件のコメント
採用された回答
David Hill
2020 年 4 月 28 日
Why not 3-dim matrix? H=N*N*h, X=N*1*x, Y=N*1*y where I assume that y=h/x.
Y=zeros(N,1,h/x);
for k=1:h/x
for m=1:x
Y(:,:,k)=Y(:,:,k)+H(:,:,x*(k-1)+m)*x(:,:,m);
end
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!