Subset and nanmean of a three dimensional array to a have a 2d array 1xndim

2 ビュー (過去 30 日間)
CARLOTTA DENTICO
CARLOTTA DENTICO 2021 年 6 月 17 日
編集済み: Matt J 2021 年 6 月 18 日
Hi, I am very new to matlab and I need your help.
I have a 3d array 609x881x348 being lonxlatxtime of sst data.
I need to subset to a specific location, calculate mean (nanmean) and reshape this array in order to have a final 1x348 array, so having the nanmean of a subset of data in that specif area of interest for 348 time period.
So far I did this:
s1pos = (lon>=12 & lon<=16 & lat>=76 & lat<=77); %609x881 logical of zeros and ones
pt_lev(:,:,1) = nanmean(pt_lev8(s1pos));
But it doesn't give what am I looking for...
Hope the question is clear.
Thank you very much!!!
  4 件のコメント
CARLOTTA DENTICO
CARLOTTA DENTICO 2021 年 6 月 18 日
Thank you!!

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

採用された回答

Matt J
Matt J 2021 年 6 月 17 日
pt_lev8=reshape(pt_lev8,[],348);
final = mean(pt_lev8(s1pos,:),1,'omitnan')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by