octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Matlab logical test case


From: Rik
Subject: Re: Matlab logical test case
Date: Sun, 02 Mar 2014 10:20:36 -0800

On 03/02/2014 10:13 AM, John W. Eaton wrote:
> On 02/28/2014 05:19 PM, Juan Pablo Carbajal wrote:
>> On Fri, Feb 28, 2014 at 11:12 PM, Rik <address@hidden> wrote:
>>> x = [-1, 0, i]
>>> logical (x)
>> ??? Error using ==> logical
>> Complex values cannot be converted to logicals.
> 
> I don't know why they wouldn't just convert any value with a non-zero
> magnitude to TRUE.  Is there some undesirable consequence of using that
> definition?
> 

I don't think so, and Octave's definition makes more sense to me.  In the
end, I just documented that there was a difference.  The docstring for
logical is now:

-- Built-in Function:  logical (X)
     Convert the numeric object X to logical type.

     Any non-zero values will be converted to true (1) while zero values
     will be converted to false (0).  The non-numeric value NaN cannot
     be converted and will produce an error.

     Compatibility Note: Octave accepts complex values as input, whereas
     MATLAB issues an error.

     See also: double, single, char.

--Rik


reply via email to

[Prev in Thread] Current Thread [Next in Thread]