Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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 commentaire
Rik
Rik le 20 Fév 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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by