hist() unable to handle an int8 vector? (UNCLASSIFIED)

David Bateman David.Bateman at motorola.com
Tue May 6 02:42:35 CDT 2008


Jankowski, Nicholas (Civ, ARL/SEDD) wrote:
> Classification:  UNCLASSIFIED 
> Caveats: NONE
>
> Was trying to generate a histogram plot of a vector using the hist()
> function.  
>
> This works
> testvector = [1 2 3 1 2 3 4 1 ];
> hist(testvector);
>
> Produces the bar plot binned as expected
>
> This, on the other hand, doesn't:
>
> testvector = uint8([1 2 3 1 2 3 4 1]);
> hist(testvector);
>
> Get the following output:
>
> error: binary operator `*' not implemented for `matrix' by `uint8
> scalar' operations
> error: evaluating binary operator `*' near line 69, column 11
> error: evaluating binary operator `+' near line 69, column 33
> error: evaluating assignment expression near line 69, column 7
> error: evaluating if command near line 66, column 3
> error: called from `hist' in file `C:\Program
> Files\Octave\share\octave\3.0.0\m\plot\hist.m'
>
> Same result for int8, int16, etc.  (anything except single or double)
>
> To make my actual program work, I had to cast it as:
> hist(double(myvector))
>
>   

You'll be happy to know it won't fail with this error with 3.0.1 as the
missing mixed operators were added. However, it'll fail differently, as
the math in the hist function will be integer based and there will
therefore be rounding effects and the bars will not be correctly drawn..
The fix is to convert all args to double class in the hist functions,
though as this fails with the other product in any case, this is not a
priority for me..

Cheers
David



-- 
David Bateman                                David.Bateman at motorola.com
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



More information about the Bug-octave mailing list