how to do the data extraction data from a 3D matrix

Hi all,
I have a 3D matrix with a dimension of (251*28*10) that I want to extract a specific data from it. As the extracted data are not in the same dimension, the empty values should be NaNs the used loop is
for i = 1:10
for j = 1:28
density(:,:,i) = find(density_1000(:,j,i)>= 27.5 & density_1000(:,j,i)<=28);
den = density_1000 (density); % this should be the finle matrix of the extracted data (251*28*10)
end
end
Any help will be appreciated.
Thanks

4 件のコメント

Rik
Rik 2018 年 10 月 7 日
Does the loop work for you? Or do you want to store NaN values to all positions with values outside of the range?
Lilya
Lilya 2018 年 10 月 7 日
I want to extract the data and put it in a matrix that the filled with nan values. as the original data is gridded so, I don't want to lose the order. this why I created the nan matrix then I want to store the extracted data in it that also should corresponding to the index.
Lilya
Lilya 2018 年 10 月 7 日
編集済み: Lilya 2018 年 10 月 7 日
the final matrix should contains the specified result for each slice of the third column (10)
Lilya
Lilya 2018 年 10 月 7 日
@Rik Wisselink
I do appreciate your response. thanks a lot

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

 採用された回答

Walter Roberson
Walter Roberson 2018 年 10 月 7 日

0 投票

mask = density_1000 >= 27.5 & density_1000 <= 28;
den = density_1000;
den(~mask) = nan;

1 件のコメント

Lilya
Lilya 2018 年 10 月 7 日
Thank you VERY much :'( this is so helpful!

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

その他の回答 (0 件)

カテゴリ

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

質問済み:

2018 年 10 月 7 日

コメント済み:

2018 年 10 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by