If function for matrix

1 view (last 30 days)
Antoni Ho
Antoni Ho on 12 Nov 2018
Commented: Antoni Ho on 12 Nov 2018
hi there
i need to do this if function
if a <= b
c = 1
else
c = realmin
but, a and b is a matrix (30x30)
and apparently i got only 1 value of c,
i want a the if function compare every cell of matrix a and b,
and gives me value in 30x30 matrix too
please help, thank you

Accepted Answer

madhan ravi
madhan ravi on 12 Nov 2018
idx=a<b
c(idx)=1
c(~idx)=realmin
  8 Comments
madhan ravi
madhan ravi on 12 Nov 2018
+1 @Torsten - an absolut genius!!
Antoni Ho
Antoni Ho on 12 Nov 2018
wow @Torsten real genius, it worked

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!