Yes, you can replace it with
if b > c
a = logical(1);
else
a = logical(0);
end
Another way of expressing this is:
if b > c
a = true;
else
a = false;
end
This is not the same as
if b > c
a = 1;
else
a = 0;
end
because in this later code, a = 1 or a = 0 assigns values of class double() to a, which behaves differently than when values of class logical() are assigned to a .
Best Answer