Confusion regarding usage of "reshape"
1 次查看(过去 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
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
回答(1 个)
Walter Roberson
2019-5-31
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!