[Top][All Lists]

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

n[:m]:end -- gap in the documentation?

From: Olaf Pohlmann
Subject: n[:m]:end -- gap in the documentation?
Date: Mon, 27 Apr 2009 18:40:34 +0100


say you want to change every other element of a vector. You can do it like this:
b = [2, 5, 7, 0.2];
b([2:2:max(size(b))]) += 4
b =

   2.0000   9.0000   7.0000   4.2000

Someone, who is familiar with Matlab, pointed out to me that the
second line can be written as
b([2:2:end]) +=4;

This feature doesn't seem to be mentionend anywhere in the docs, and
even the tutorial sections about ranges
and index expressions
keep quiet about it, but it does work, and it seems to be implemented
since version 2.x already.

Is this just a gap in the documentation or are there circumstances
where it doesn't work reliably (yet)?


reply via email to

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