[Scilab-users] array constructors

Heinz Nabielek heinznabielek at me.com
Tue Oct 2 21:51:36 CEST 2018


On 02.10.2018, at 21:12, Samuel Gougeon <sgougeon at free.fr> wrote:
> 
> Le 02/10/2018 à 21:02, Heinz Nabielek a écrit :
>> On 02.10.2018, at 20:31, Samuel Gougeon <sgougeon at free.fr> wrote:
>>> Le 02/10/2018 à 18:37, Adelson Oliveira a écrit :
>>>> Hi,
>>>> 
>>>> In scilab 6.1, I've noticed that the array
>>>> 
>>>> [8.9:0.2:9.9] does contain 8.9 and 9.9,
>>>> 
>>>> but the array,
>>>> 
>>>> [-5.1:0.2:5.1]
>>>> 
>>>> does not contain the last element 5.1!
>>>> 
>>>> find([-5.1:0.2:5.1] == 5.1) = []
>>>> 
>>>> Why is that?
>>>> 
>>>> Isn't it a bug?
>>> We have
>>> --> a = -5.1:0.2:5.1;
>>> --> delta = a($)+0.2-5.1
>>>  delta  =
>>>    8.882D-16
>>> 
>>> --> delta/5.1/%eps
>>>  ans  =
>>>    0.7843137
>>> 
>>> So, computing the next value leads to 5.1 but with an excess within the epsilon machine.
>>> Because of this excess, this last value is not included in the output set.
>>> 
>>> I am wondering whether we could detect this kind of edge effects, and manage them more softly.
>>> 
>>> Samuel
>> 
>> UNDERSTOOD. But what is a safe way to plot histograms like histplot(a:b:c, X) where X is a one-dimensional array?
> 
> histplot(linspace(a, c, round((c-a)/b), X)
> or
> histplot(a:b:nearfloat("succ",c), X)

THANKS THE LOT. I had all sort of problems in the past.....
Heinz


More information about the users mailing list