3d to 2d matrix

9 次查看(过去 30 天)
I need to convert this "u" 3d matrix in a 2d numerical matrix, without having to cut and paste number by number in a new one, just like the "u2" example.
Thank you for any help!

采纳的回答

Joseph Cheng
Joseph Cheng 2021-6-22
take a look at the function squeeze()
for ind = 1:3
val(1,1,ind)=-ind;
end
disp(val)
(:,:,1) = -1 (:,:,2) = -2 (:,:,3) = -3
u2 = squeeze(val);
disp(u2)
-1 -2 -3
  2 个评论
Joseph Cheng
Joseph Cheng 2021-6-22
if the starting matrix is a bit more complicated you can also use reshape() as well

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by