Mercurial > octave
changeset 28487:a7fcdac012d8 stable
doc: Fix incorrect example code in Vectorize chapter (bug #58607).
* vectorize.txi: Define 'n = length (A) - 1;' to avoid overstepping index
bounds.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 17 Jun 2020 14:41:13 -0700 |
parents | 36c6bd835ec9 |
children | 4304bf2b450b d2fd4616829b |
files | doc/interpreter/vectorize.txi |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/vectorize.txi Tue Jun 16 17:03:13 2020 -0400 +++ b/doc/interpreter/vectorize.txi Wed Jun 17 14:41:13 2020 -0700 @@ -693,9 +693,9 @@ @example @group -n = length (A); +n = length (A) - 1; B = zeros (n, 2); -for i = 1:length (A) +for i = 1:n ## this will be two columns, the first is the difference and ## the second the mean of the two elements used for the diff. B(i,:) = [A(i+1)-A(i), (A(i+1) + A(i))/2];