To compare to matrices element by element
Show older comments
i have matrix A= [ 1 2 2 , 4 5 6] and matrix B = [ 1 2 3 , 2 3 4 ] . want to caompare element by element martix operators and any one element or all element in A if lessthan B should return matrix A is lesser .
1 Comment
Torsten
on 21 Jul 2021
if A <= B
disp('A is less or equal B')
end
Accepted Answer
More Answers (1)
you can compare matrix A and B directly using typical comparing operators
A<B
if the question is if there is any element of A smaller than the corresponding element in B, you can use e.g.
any(A<B,'all')
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!