Convert a 4D segmented matrix to a 3D one?

24 ビュー (過去 30 日間)
Mohammad Saleh
Mohammad Saleh 2019 年 9 月 22 日
回答済み: Athul Prakash 2019 年 9 月 25 日
I have a 4D segmented matrix of ones and zeros with the size 4 512 512 150. how do i convert this to a 3D matrix of size 512 512 150?
  1 件のコメント
Anton Gribovskiy
Anton Gribovskiy 2019 年 9 月 22 日
Converted matrix has less elements than original one. How do you want to remove these extra elements? I think an example would help.

サインインしてコメントする。

採用された回答

Athul Prakash
Athul Prakash 2019 年 9 月 25 日
Hey Mohammad,
Going by those input and output dimensions, I am assuming that you want to extract a part of the matrix with a given value in dimension 1.
If you want to get ith value from dimension 1, use:
crop = mat(i,:,:,:);
to get 'crop' of size [1 512 512 150].
Then use the squeeze function to remove all dimensions of size 1.
crop = squeeze(crop); %this makes size = [512 512 150]
Have a look at the doc for squeeze
Cheers!

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by