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!