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 Comment

You might want to read some of this: http://www.mathworks.com/help/techdoc/learn_matlab/bqr_2pl.html

Sign in to comment.

 Accepted Answer

anyNegativeA = any(A(:)<0);
if anyNegativeA
B = A*2;
end

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!