[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Invalid index error
From: |
Rich Shepard |
Subject: |
Invalid index error |
Date: |
Sun, 1 Aug 2004 14:52:09 -0700 (PDT) |
I've extracted a row from a matrix using
octave> a1 = foo(1,:)
This row vector has 6 elements. Now I want the product of the elements so
I write:
octave:17> bar = a1(1)
bar = 1
octave:18> for i = 1:6
> bar = bar * a1 (i+1)
> endfor
The result I get is numerically correct, but then there's the error
message:
bar = 144
error: invalid vector index = 7
error: evaluating binary operator *' near line 19, column 11
error: evaluating assignment expression near line 19, column 5
error: evaluating for command near line 18, column 1
If I'm correctly reading the manual, defining the range of the for loop as
1:6 should end the loop with element 6. What syntactical error have I made?
(This is with 2.1.57).
Thanks,
Rich
--
Dr. Richard B. Shepard, President
Applied Ecosystem Services, Inc. (TM)
<http://www.appl-ecosys.com>
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- Invalid index error,
Rich Shepard <=
- Message not available
- Message not available
- Re: Invalid index error, Geraint Paul Bevan, 2004/08/01
- Re: Invalid index error, Rich Shepard, 2004/08/01
- Re: Invalid index error, Geraint Paul Bevan, 2004/08/01
- Re: Invalid index error, Rich Shepard, 2004/08/01
- Re: Invalid index error, Geraint Paul Bevan, 2004/08/01
- Re: Invalid index error, Rich Shepard, 2004/08/01
- Re: Invalid index error, Geraint Paul Bevan, 2004/08/01