array multiplication and addition

2 vues (au cours des 30 derniers jours)
anindita Roy
anindita Roy le 28 Avr 2020
Commenté : anindita Roy le 6 Mai 2020
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.

Réponse acceptée

David Hill
David Hill le 28 Avr 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
  1 commentaire
anindita Roy
anindita Roy le 6 Mai 2020
Thanks for this answer. But for the further process I need the Y as cell matrix in generic form.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by