If function for matrix

9 Ansichten (letzte 30 Tage)
Antoni Ho
Antoni Ho am 12 Nov. 2018
Kommentiert: Antoni Ho am 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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by