Confusion regarding usage of "reshape"
Show older comments
Hi
During working on a project using Matlab R2018b, I came across a function, called "reshape". I try to understand how does it work and got stuck in 2 calculations where this dimesion matters.
Situation 1:
d=[1
0]
t=[val(:,:,1,1) = 0.0016
val(:,:,2,1) =-4.7149e-04
val(:,:,1,2) =-7.2994e-04
val(:,:,2,2) =0.0027
]
I have tried to multiply d[1] with val(:,:,1,1) and val(:,:,2,1). And d[2] with val(:,:,1,2) and val(:,:,2,2)
I have written this code :
NewB = zeros(1,1,20,500);
NewB(i)=(d(i)*t(i));// i is for iteration through 4 th dimension of t
But I found that the my code multiplies only d[1] with val(:,:,1,1) and d[2] with val(:,:,1,2) only. I think , I need to alter the dimensions in calculation, right?
Situation 2:
A is of size [1 x 1 x 20 x 500] and B is of size [1 x 1 x 100 x 20]
I reshaped B following this:
B= reshape(B, 1,1,20,100);
Now I would like to multiply A[1 x 1 x 20 x1] with B[1x 1x 20 x1] and continue it for the remaining list.
Can you adivse me how to approach this problem?
thanks,
2 Comments
Greg Heath
on 1 Jun 2019
Clarify your notation so that the interpretation of the variable x and the times symbol "x" will not get confused
Hope this helps
Greg
Saugata Bose
on 1 Jun 2019
Answers (1)
Walter Roberson
on 31 May 2019
0 votes
See bsxfun(), and https://blogs.mathworks.com/loren/2016/10/24/matlab-arithmetic-expands-in-r2016b/ implicit expansion .
Or repmat() so the values are the same size.
1 Comment
Saugata Bose
on 31 May 2019
Categories
Find more on Evaluation 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!