Confusion regarding usage of "reshape"

2 次查看(过去 30 天)
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 个评论
Greg Heath
Greg Heath 2019-6-1
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 2019-6-1
@Greg
thanks. i have edited the question as per ur advise. hope it will help u to help me.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2019-5-31
Or repmat() so the values are the same size.
  1 个评论
Saugata Bose
Saugata Bose 2019-5-31
@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)?

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by