find minimum value greater than zero in the rows

a=[9,32,7,0,0,0,0,0;15,32,9,0,0,0,0,0;25,42,0,0,0,0,0,0];i have to find out minimum value in 'a' which should be greater than zero.my answer has to be b=[7;9;25].suggest some points

 Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 10 de Jun. de 2014
a(a == 0) = inf;
b = min(a,[],2);

3 comentarios

Image Analyst
Image Analyst el 10 de Jun. de 2014
Editada: Image Analyst el 10 de Jun. de 2014
I think you mean
a(a <= 0) = inf;
so that the code can handle elements of a that might be less than zero also. It's just more general since he didn't specify the range of values that a might have.
Bathrinath
Bathrinath el 10 de Jun. de 2014
Thank you sir
Andrei Bobrov
Andrei Bobrov el 10 de Jun. de 2014
Thank you Image Analyst! I agree with you.

Iniciar sesión para comentar.

Más respuestas (1)

Matt J
Matt J el 10 de Jun. de 2014
Editada: Matt J el 10 de Jun. de 2014
The min command plus
a(a<=0)=nan;

Categorías

Más información sobre MATLAB Mobile Fundamentals en Centro de ayuda y File Exchange.

Preguntada:

el 10 de Jun. de 2014

Comentada:

el 10 de Jun. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by