help-octave
[Top][All Lists]
Advanced

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

Re: How to leave out selected elements from a vector?


From: Primoz PETERLIN
Subject: Re: How to leave out selected elements from a vector?
Date: Fri, 18 Jul 2008 15:54:53 +0200

Thanks to all who responded (I was clumsy before and didn't include
the list as Cc:)

All the best, Primož

2008/7/18 Ben Abbott <address@hidden>:
>
> On Jul 17, 2008, at 7:41 AM, Bill Denney wrote:
>
>> Francesco Potorti` wrote:
>>>>> 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)=[];
>>>
>> 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:
>> 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
>
> I like the "end" feature as well.
>
> list([1:m-1, n+1:end])
>
> Ben
>
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www.cae.wisc.edu/mailman/listinfo/help-octave
>



reply via email to

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