fine negative value entries in a matrix

Hello.. i am a Matlab beginner.. i have a question.. How to check if there's entry in a matrix is negative value.. i.e A = [1 -2 3;2 3 -4;3 4 5].. then i wanna do like this: if (any entry in A < 0); B = A*2; end.. tq

1 comentario

the cyclist
the cyclist el 28 de Jul. de 2011
You might want to read some of this: http://www.mathworks.com/help/techdoc/learn_matlab/bqr_2pl.html

Iniciar sesión para comentar.

 Respuesta aceptada

the cyclist
the cyclist el 28 de Jul. de 2011
anyNegativeA = any(A(:)<0);
if anyNegativeA
B = A*2;
end

Más respuestas (0)

Categorías

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by