I want to compare each element in 2 matrix same size and display a text in every case.

1 view (last 30 days)
i want to compare 2 matrix lets say A=[1 2 3 4 5] and B=[2 4 9 8 2 ] and if elemnt A<B then display a custom text
like this
[ yes yes yes yes no ]

Accepted Answer

Matt J
Matt J on 22 May 2022
A=[1 2 3 4 5];
B=[2 4 9 8 2 ];
t=["no", "yes"];
t((A<B)+1)
ans = 1×5 string array
"yes" "yes" "yes" "yes" "no"

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!