How to compare elements of two equal size matrices by logical conditionals?
1 view (last 30 days)
Show older comments
Hello everyone! I have been struggling with this...
I would like to compare the elements of matrix A with the elements of matrix B, then get in matrix C the elements which have accomplished the logical condition. All matrices having the same size (12 x 1).
Eg,: if A (1,1) <= B (1,1) , then C (1,1) = A (1,1). If NOT then C (1,1) = B (1,1)...
How can I formulate it? ...
Many thanks indeed. Best Regards, MF
0 Comments
Accepted Answer
madhan ravi
on 16 Oct 2018
for i = 1:numel(A)
if A(i)<=B(i)
C(i) = A(i)
else
C(i) = B(i)
end
end
4 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices 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!