help-octave
[Top][All Lists]
Advanced

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

Re: Excluding elements of a matrix (Joseph Wakeling)


From: Francesco Potorti`
Subject: Re: Excluding elements of a matrix (Joseph Wakeling)
Date: Mon, 25 Dec 2006 22:59:07 +0100

>> octave:2> A = magic(4)
>> A =
>> 
>>    16    2    3   13
>>     5   11   10    8
>>     9    7    6   12
>>     4   14   15    1
>> 
>> octave:3> A(1:end ~= 2,:)
>> ans =
>> 
>>    16    2    3   13
>>     9    7    6   12
>>     4   14   15    1
>
>That's a nice way.  Is there a comparable way of subtracting _several_
>elements?

Apparently, the already mentioned setdiff works in this case also:

octave:3> A(setdiff(1:end,[2 3]),:)
ans =

   16    2    3   13
    4   14   15    1

I'm admired.

-- 
Francesco Potortì (ricercatore)        Voice: +39 050 315 3058 (op.2111)
ISTI - Area della ricerca CNR          Fax:   +39 050 315 2040
via G. Moruzzi 1, I-56124 Pisa         Email: address@hidden
Web: http://fly.isti.cnr.it/           Key:   fly.isti.cnr.it/public.key


reply via email to

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