2

How would you implement:

if(m <= 0.1)
...
end

if m is not a scalar. I tried something along those lines:

array = ones(length(m), 1)  .* 0.1;
if(m <= array)
...
end

without success.

Eitan T
  • 32,660
  • 14
  • 72
  • 109
cs0815
  • 16,751
  • 45
  • 136
  • 299
  • What is m ? And what it means m<=0.1 if m is not a scalar? – Adiel Jul 01 '13 at 13:35
  • related question: [how to threshold/filter a vector?](http://stackoverflow.com/questions/16132231/how-to-threshold-filter-a-vector) – Eitan T Jul 01 '13 at 13:57

1 Answers1

3

You likely want

if all(m <= 0.1)

but maybe

if any(m <= 0.1)

It's even one of the examples for the all function.

But in fact the documentation for if suggests that

if (m <= 0.1)

should work just fine also.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720