Confusion regarding usage of "reshape"

1 view (last 30 days)
Saugata Bose
Saugata Bose on 31 May 2019
Commented: Saugata Bose on 1 Jun 2019
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
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
Saugata Bose on 1 Jun 2019
@Greg
thanks. i have edited the question as per ur advise. hope it will help u to help me.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 31 May 2019
Or repmat() so the values are the same size.
  1 Comment
Saugata Bose
Saugata Bose on 31 May 2019
@Walter Roberson
Thank you for sharing me the tutorial.
I think repmat() will help me solving situation2. But what would be the way to solve solution 1 where I would like to multiply one value from d with val(:,:,1,1) and with val(:,:,2,1)?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!