|
From: | Bill Denney |
Subject: | Re: How to leave out selected elements from a vector? |
Date: | Thu, 17 Jul 2008 07:41:53 -0400 |
User-agent: | Thunderbird 2.0.0.14 (Windows/20080421) |
Francesco Potorti` wrote:
And if you don't want to actually remove the value from your list, but you just want to do a calculation on a subset (not quite what you asked, but often what you asked for is for this purpose), you can index the vector:Here is my question. In Mathematica, there exists a function called Drop, which I often use to manipulate lists, e.g., Drop[ list, {m, n} ] returns the argument list with the elements m through n omitted from the list (the resultant list is shorter for (n - m + 1) elements). Does anything similar already exist in Octave? I know I can program it myself, but I wouldn't want to reinvent the wheel. :)Use indexing. For instance [list(1:m-1), list(n+1:end)] could do what you want.Assuming, as Michael did, that you want to remove elements from an array, you can alternatively do list(m:n)=[];
with the indexes themselves list([1:m-1 n+1:length(list)]) or with a logical vector mask = false(size(list)); mask(m:n) = true; list(mask) Have a good day, Bill
[Prev in Thread] | Current Thread | [Next in Thread] |