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