Info

This question is closed. Reopen it to edit or answer.

matrix manipulation and changing matrix dimension using Reshape, Squeeze,..

1 view (last 30 days)
Good morning Matlab community,
I will try to make the question simpler since it was not clear for someone to understand, sorry.
I have one matrix A(73400 by 30) 2D.
Another one B(14680 by 5 ).
the number of rows in A; 73400 are basically (5*1) arrays stacked up that I extracted from a bigger matrix (5*5 by 14680 by 30) since I only need the 1st column of each 5*5 matrix (total of 14680 of them and in all the 30 sets).
Objective is to compute the sum pf the product between the transpose of each (5*1) from A and each row from B ( across all 30 columns of A). (1*5 times 1*5 = 1 element).
The final Matrix output should then be C(14680*30)
Please see an extracted example from these matrices,
Thank you so much
below is the code:
%%%%%%Extracted 10 rows and 3 columsn from A(73400 by 30)(noting that nbr
%%%%%%or rows in A is = (14680 of (5*1) stacked) so that's why I need to
%%%%%%do the sump of the product in 5 rows at the time from A
%%%Matrix B(14680*5)
%%Objective Matrix is C(14680*30) with each element in C(i,j)= sumProduct(transpose(A(5*1).*B(i,:))
%%Example:
A1=[-20.6860046107437,-20.8259490953586,-20.5295141167041;-4.68083651024847,-4.38170600425412,-4.04039850536564;-5.32219353656980,-4.99820840303045,-4.62367652177701;0,0,0;0,0,0;-13.3475398510192,-10.9590900264805,-8.87951051472035;-0.0119489044851285,-0.00952917816601411,-0.00754907814411214;0,0,0;0,0,0;0,0,0];
B11=[2.48618841134752e-06,1.78727800000000e-06,0,0,0;2.56419915269461e-06,1.78727800000000e-06,0,0,0];
C(1,1)=sum(A1(1:5,1)'.*B11(1,:)) % 1st element in C(14680*30)
C(2,1)=sum(A1(6:10,1)'.*B11(2,:))% 2nd element in C(14680*30)
....
%%until all the 14680 of (5*1) are reached so C(14680*1)
%%now same thing needs to be done but moving in the 2nd Column of A(:,2)
C(1,2)=sum(A1(1:5,2)'.*B11(1,:)) % Still 1st row of B
C(2,2)=sum(A1(6:10,2)'.*B11(2,:))% Still 2nd row of B
%%continue until all 14680 rows and 14680 of (5*1) are used, then move to
%%next column nbr 3 from A(:,3)
C(1,3)=sum(A1(1:5,3)'.*B11(1,:)) % Still 1st row of B
C(2,3)=sum(A1(6:10,3)'.*B11(2,:))% Still 2nd row of B
%%%the final dimension of C is then (14680 by 30)
  4 Comments
Walter Roberson
Walter Roberson on 4 Jan 2017
Amine Ben Ayara comments to Guillaume:
What are you talking about? where exactly do you see the duplication? I even attached the example in m.file?
Walter Roberson
Walter Roberson on 4 Jan 2017
If you had a revised code version or example you should have updated that question rather than creating a new question.

Answers (0)

Community Treasure Hunt

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

Start Hunting!