array multiplication and addition
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
anindita Roy
il 28 Apr 2020
Commentato: anindita Roy
il 6 Mag 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.
0 Commenti
Risposta accettata
David Hill
il 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
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!