Deleting a unit dimension of a matrix

14 ビュー (過去 30 日間)
ANKUR KUMAR
ANKUR KUMAR 2017 年 10 月 30 日
編集済み: Walter Roberson 2017 年 10 月 30 日
My matrix size is 1*250*500; How can I change this matrix into 250*500.

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 30 日
編集済み: Walter Roberson 2017 年 10 月 30 日
squeeze() if you want to delete all unit dimensions (provided that the matrix is at least 3d).
permute() the dimension out of the way if you want to move a specific dimension.
For example,
M = rand(1,250,1,500);
size(squeeze(M)) %gets rid of both 1's, leaving 250 x 500
size(permute(M, [2 3 4 1]) %moves dimension 1 to the fourth dimension, leaving 250 x 1 x 500 x 1 but the trailing 1 is not displayed so 250 x 1 x 500

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by