Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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 Kommentar
Rik
Rik am 20 Feb. 2017
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by