Loops and Complicated Matrix Multiplication
Show older comments
Hello,
This may be simple to figure out but for some reason I can't seem to get the results I want.
I'm trying to multiply two matrices together using a loop, in which the matrix dimensions do not agree. I know this impossible to do using the standard matrix arithmetic. What I would like to do is multiply each column from matrix (Txcouple 41x40x40) against a page in the other matrix (dpTxcouple1 41x17x1600). There should be 1600 pages in the resulting answer but I am unsure how to do this. Here is what I have so far. I can manage to populate the first page with the correct result, but the other pages are filled with zeros.
for k=1:40;
for m=1:17
for g=1:40;
for i=(f-1) * 40 + g;
Tx1Final(:,m,i)=Txcouple(:,k,g).*dpTxcouple1(:,m,i);
end
end
end
end
Any help would be greatly appreciated.
Thanks!
Josh
Accepted Answer
More Answers (1)
Azzi Abdelmalek
on 5 Sep 2012
Edited: Azzi Abdelmalek
on 5 Sep 2012
[n,m,l]=size(A);[n1,m1,l1]=size(B);v=[];
for i1=1:l
for k=1:m
v=[v bsxfun(@times, A(:,i1,k),B)];
end
end
Categories
Find more on Loops and Conditional Statements 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!