how to extract data after squeeze the matrix?

i have 3D data that will be squeezed to 2D data matrix. the data is 116x150x45 where after the squeeze, i want to take out sample 1-25 only,
thus, Y should have 25 for Y(1) until Y(25), but i only got Y that will extract and replace after squeezing. anyone can help?
for a = 1:25
Y=squeeze(fmridata(:,:,a)); % for healthy patients from 1-25
end

3 件のコメント

Adam
Adam 2019 年 10 月 14 日
You would be far better off just taking
fmridata( :, :, 1:25 )
and working with it from there via indexing.
Muaaz Badrul
Muaaz Badrul 2019 年 10 月 14 日
but the data will still be in 3D right? or it will be converted into 2D matrix?
Adam
Adam 2019 年 10 月 14 日
It will still be stored in 3d yes. But how it is stored in a variable doesn't really matter. It's what you do with it from there that matters.

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

 採用された回答

Rik
Rik 2019 年 10 月 14 日

0 投票

Something like this is probably what you're looking for, although it makes it more difficult to compare the same pixel over all patients.
Y=cell(1,25);
for a = 1:25
Y{a}=squeeze(fmridata(:,:,a)); % for healthy patients from 1-25
end

4 件のコメント

Stephen23
Stephen23 2019 年 10 月 14 日
編集済み: Stephen23 2019 年 10 月 14 日
Note that for a scalar a used as an index fmridata(:,:,a) returns an array with size 116x150 and thus squeeze is superfluous.
Muaaz Badrul
Muaaz Badrul 2019 年 10 月 14 日
does this mean that the array of 116x150 have 25 layers? i need it slice by slice like Y1 , Y2, until Y25
Rik
Rik 2019 年 10 月 14 日
My code will result in a cell array with 25 elements, where each cell contains a matrix of 116x150. This avoids numbered variables, which are a bad idea in general.
As indicated by others: The squeeze is not needed, and a 3D array is probably a better idea, depending on what you want to do next with this array.
Muaaz Badrul
Muaaz Badrul 2019 年 10 月 14 日
okay thanks for your help.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

質問済み:

2019 年 10 月 14 日

コメント済み:

2019 年 10 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by