Help with linspace

10 messages
Open this post in threaded view
|

Help with linspace

 Could someone with access to Matlab try the following? linspace(-0, 0, 5) Octave returns ans =   -0   0   0   0   0 which is pretty silly unless it is required for compatibility. --Rik
Open this post in threaded view
|

Re: Help with linspace

 Administrator > On Jan 6, 2018, at 7:23 AM, Rik <[hidden email]> wrote: > > Could someone with access to Matlab try the following? > > linspace(-0, 0, 5) > > Octave returns > > ans = > >   -0   0   0   0   0 > > which is pretty silly unless it is required for compatibility. > > —Rik Using R2016a ... linspace(-0, 0, 5) ans =      0     0     0     0     0 Ben
Open this post in threaded view
|

Re: Help with linspace

 Ben Abbott writes: >> On Jan 6, 2018, at 7:23 AM, Rik <[hidden email]> wrote: >> >> Could someone with access to Matlab try the following? >> >> linspace(-0, 0, 5) >> >> Octave returns >> >> ans = >> >>   -0   0   0   0   0 >> >> which is pretty silly unless it is required for compatibility. >> >> —Rik > > Using R2016a ... > > linspace(-0, 0, 5) > > ans = > >      0     0     0     0     0 > > Ben Matlab does not show the sign of 0. In fact it does indeed return [-0, 0, 0, 0, 0]. An easy way to check is 1./(linspace(-0, 0, 5)) ans =   -Inf   Inf   Inf   Inf   Inf Joel
Open this post in threaded view
|

Re: Help with linspace

 In reply to this post by bpabbott On 01/06/2018 07:56 AM, Ben Abbott wrote: >> On Jan 6, 2018, at 7:23 AM, Rik <[hidden email]> wrote: >> >> Could someone with access to Matlab try the following? >> >> linspace(-0, 0, 5) >> >> Octave returns >> >> ans = >> >>   -0   0   0   0   0 >> >> which is pretty silly unless it is required for compatibility. >> >> —Rik > Using R2016a ... > > linspace(-0, 0, 5) > > ans = > >      0     0     0     0     0 > > Ben > > > Okay, silly, but overruled. --Rik
Open this post in threaded view
|

Re: Help with linspace

 On 01/06/2018 05:44 PM, Rik wrote: ```On 01/06/2018 07:56 AM, Ben Abbott wrote: ``` ```On Jan 6, 2018, at 7:23 AM, Rik [hidden email] wrote: Could someone with access to Matlab try the following? linspace(-0, 0, 5) Octave returns ans = -0 0 0 0 0 which is pretty silly unless it is required for compatibility. —Rik ``` ```Using R2016a ... linspace(-0, 0, 5) ans = 0 0 0 0 0 Ben ``` ```Okay, silly, but overruled. --Rik ``` Right! Pretty cute of Matlab to hide the -
Open this post in threaded view
|

Re: Help with linspace

 In reply to this post by Urathai On 01/06/2018 11:04 AM, Joel Dahne wrote: > Ben Abbott writes: > [snip] >> Using R2016a ... >> >> linspace(-0, 0, 5) >> >> ans = >> >>       0     0     0     0     0 >> >> Ben > > Matlab does not show the sign of 0. In fact it does indeed return [-0, > 0, 0, 0, 0]. An easy way to check is > > 1./(linspace(-0, 0, 5)) > > ans = > >    -Inf   Inf   Inf   Inf   Inf Nice manner of testing...  Consider adding this to the list of linspace compatibility tests in data.cc: Dan
Open this post in threaded view
|

Re: Help with linspace

 On 01/06/2018 07:20 PM, Daniel J Sebald wrote: > On 01/06/2018 11:04 AM, Joel Dahne wrote: >> Ben Abbott writes: >> > [snip] >>> Using R2016a ... >>> >>> linspace(-0, 0, 5) >>> >>> ans = >>> >>>       0     0     0     0     0 >>> >>> Ben >> >> Matlab does not show the sign of 0. In fact it does indeed return [-0, >> 0, 0, 0, 0]. An easy way to check is >> >> 1./(linspace(-0, 0, 5)) >> >> ans = >> >>    -Inf   Inf   Inf   Inf   Inf > > Nice manner of testing...  Consider adding this to the list of > linspace compatibility tests in data.cc: > > Dan > Actually, on Matlab R2017b  >> linspace(-0, 0, 5) ans =       0     0     0     0     0  >> 1./linspace(-0, 0, 5) ans =    -Inf  -Inf  -Inf  -Inf  -Inf and  >> linspace(0, -0, 5) ans =       0     0     0     0     0  >> 1./linspace(0, -0, 5) ans =     Inf   Inf   Inf   Inf   Inf -- Michele Ginesi
Open this post in threaded view
|

Re: Help with linspace

 Administrator On 01/06/2018 02:00 PM, michele wrote: >  >> 1./linspace(-0, 0, 5) > > ans = > >    -Inf  -Inf  -Inf  -Inf  -Inf I guess it's an optimization of sorts.  It also seems pretty funny because I think the final value is normally set to be the one given as the end point.  Though I guess not in this case now. jwe