フィルターのクリア

how to find the first nonzero value of a multidimensional matrix, with a certain value for some dimensions in that matrix

1 回表示 (過去 30 日間)
I want to find the first nonzero element in a matrix, I'm now using
idx = find(NH3summer==min(NH3summer(NH3summer>0)));
[E,B,M,P,U,L] = ind2sub(size(NH3summer),idx);
NH3summer is a 6D matrix, but now i want to find the first nonzero value of NH3summer(:,B1,:,:,:,:) How can i index NH3summer so that it only looks in B1 for the second dimension? Thanks!
  1 件のコメント
Rik
Rik 2017 年 2 月 20 日
Doesn't the code below work?
temp=NH3summer(:,B1,:,:,:,:);
idx = find(temp==min(temp(temp>0)));
[E,B,M,P,U,L] = ind2sub(size(temp),idx);
B=B1;
B will be 1 by definition, so we can ignore that one by setting it to B1.

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

回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by