If function for matrix

조회 수: 9 (최근 30일)
Antoni Ho
Antoni Ho 2018년 11월 12일
댓글: Antoni Ho 2018년 11월 12일
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

채택된 답변

madhan ravi
madhan ravi 2018년 11월 12일
idx=a<b
c(idx)=1
c(~idx)=realmin
  댓글 수: 8
madhan ravi
madhan ravi 2018년 11월 12일
+1 @Torsten - an absolut genius!!
Antoni Ho
Antoni Ho 2018년 11월 12일
wow @Torsten real genius, it worked

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by