Confusion regarding usage of "reshape"

1 回表示 (過去 30 日間)
Saugata Bose
Saugata Bose 2019 年 5 月 31 日
コメント済み: Saugata Bose 2019 年 6 月 1 日
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