Discussion:
max value : problem with array
LucaLuca
2018-10-19 21:22:12 UTC
Permalink
hi,
look that:

a=[3 6 4 7 3]
a =

3 6 4 7 3

max(a)
=

error: A(I): index out of bounds; value 7 out of bound 5

why?

the help online about max write:

Find maximum values in the array x.

For a vector argument, return the maximum value.



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
Andreas Weber
2018-10-20 14:51:23 UTC
Permalink
Post by LucaLuca
hi,
a=[3 6 4 7 3]
a =
3 6 4 7 3
max(a)
=
error: A(I): index out of bounds; value 7 out of bound 5
why?
I'm sure you've overwirtten "max" which you can show with "which max".
Typically this shows:

octave:2> which max
'max' is a built-in function from the file libinterp/corefcn/max.cc

but as soon as you've overwritten it:


octave:3> max = 5
max = 5
octave:4> which max
'max' is a variable

Loading...