|
On Oct 1, 9:46 pm, "Jos " <#10...@fileexchange.com> wrote:
> "Patrick Diviacco" <patrick.divia...@gmail.com> wrote in message <ha1pjm$gl...@fred.mathworks.com>...
> > hi,
>
> > is there any better way to write this in MATLAB ?
>
> > if (binNumber2 == 0)
> > binNumber2 = 1;
> > end
>
> > thanks
>
> There are several ways of doing things like this. It also depends what you want to do if binNumber2 is not zero, can have other values than 0 or 1, and whether it is an array or not.
>
> A = true, A = ~A,
> B = 1, B = 1-B
> C = [0 11 12 13 14], C(C==0) = 1
> etc.
>
> hth
> Jos
And of course these methods apply if and only if the numbers are
integers.
If the numbers are floating point, then these methods don't work at
all.
|