Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 comentario
Rik
Rik el 20 de Feb. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by