COnvert 3d matrix to 2D

12 次查看(过去 30 天)
Joana
Joana 2019-12-5
I have a matrix of x=1200x30x410, i need to change it to 2D as x=3600x410. How to do that.?
it gives an error by using reshape that 'Product of known dimensions, 410, not divisible into total number of elements, 3672000'

回答(1 个)

Star Strider
Star Strider 2019-12-5
The reshaped matrix has to be (36000 x 410).
x = rand(1200,30,410); % Create Matrix
y = reshape(x,[],410);
You can reduce the first dimension afterwards, if necessary.
  2 个评论
Joana
Joana 2019-12-5
It doesn't work actually. Here's the x for example i need to change.
y should be equal to 6000x102
Star Strider
Star Strider 2019-12-5
Please define ‘doesn’t work’.
It works for me:
D = load('matlab.mat');
x = D.x;
y = reshape(x, [], 102);
whos('y')
producing:
Name Size Bytes Class Attributes
y 6000x102 4896000 double

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by