help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Smartly accessing the last element of a vector / matrix


From: Paul Kienzle
Subject: Re: Smartly accessing the last element of a vector / matrix
Date: Thu, 18 Nov 2004 06:26:03 -0500

x(1,end), x(1,end-1) ...

- Paul

On Nov 18, 2004, at 6:14 AM, Ploett Norbert wrote:

Hello,

a question just in case I missed something in the manuals:

Is there a more concise notation to access the last element e.g. of a
vector? I am writing things like:

x = rand(1,10);
lastx = x(1,columns(x));

Wouldn't it be snappy to write something Python-like:

lastx = x(1,-1);

and then

butlastx = x(1,-2);

etc.

Anybody have any hints?


Norbert



-------------------------------------------------------------
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
-------------------------------------------------------------




-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]