[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Matlab logical test case
From: |
Juan Pablo Carbajal |
Subject: |
Re: Matlab logical test case |
Date: |
Sun, 2 Mar 2014 20:54:56 +0100 |
On Sun, Mar 2, 2014 at 7:20 PM, Rik <address@hidden> wrote:
> 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
Bold! I like it.