array multiplication and addition
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
David Hill
on 28 Apr 2020
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
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices 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!