Various questions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Various questions

Wichaya Changwatchai
Several questions:

1) The section on range constants says that:

        Octave does not convert range constants to vectors unless it is
        necessary to do so.

When would it NOT be necessary to convert a range constant to a vector?  Would
an example be, say, a for loop?

2) Is there a way to subscript a constant range, e.g.

        [2:2:10](2:4)

as opposed to having to assign it to a dummy variable:

        a = [2:2:10];
        a(2:4)

3) The operators .+ and .- don't seem to work, as documented in the manual (of
course, they ARE redundant with + and -).  Have they been disabled?

Top
--
W. Top Changwatchai
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Various questions

John Eaton-4
[hidden email] (Wichaya Changwatchai) wrote:

: 1) The section on range constants says that:
:
: Octave does not convert range constants to vectors unless it is
: necessary to do so.
:
: When would it NOT be necessary to convert a range constant to a
: vector?  Would an example be, say, a for loop?

Yes.  Also, assignment of a range to a variable does not cause a
conversion.

Currently, indexing a range will cause the original range to be
converted to a vector, and the result will be a vector, not a range.
This is because it was easier to implement -- the code for indexing
matrices already had to be written, and I have not had time to
implement a new set of functions for indexing ranges as a special
case.  This might be a good project for a volunteer.  :-)

: 2) Is there a way to subscript a constant range, e.g.
:
: [2:2:10](2:4)
:
: as opposed to having to assign it to a dummy variable:
:
: a = [2:2:10];
: a(2:4)

Not yet.  This might be a useful extension, but it is not likely to
make it to the top of my to-do list any time soon.

: 3) The operators .+ and .- don't seem to work, as documented in the
: manual (of course, they ARE redundant with + and -).  Have they
: been disabled?

Oops.  This will be fixed in the next release.

jwe