remove some element from array

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

remove some element from array

turbofib
i try it:

D=[2 3  6  7   5   4}

v=[ 3 2 4]

i want to remove  in D the element v

ans:[2 3 4]



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

Doug Stewart-4


On Sat, Feb 9, 2019 at 9:00 PM turbofib <[hidden email]> wrote:
i try it:

D=[2 3  6  7   5   4}

v=[ 3 2 4]

i want to remove  in D the element v

ans:[2 3 4]



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html




>> D=[2 3  6  7   5   4]
D =

   2   3   6   7   5   4

>> D(3)=[]
D =

   2   3   7   5   4


The 6 was removed.

--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

turbofib
Hi,

I want remove all element v....not only 1 element



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

Andreas Weber-6
Am 10.02.19 um 09:15 schrieb turbofib:
> I want remove all element v....not only 1 element

I guess Doug thought that you would be able to modify his example and
replace 3 with v...


Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

turbofib
This post was updated on .
there is a problem

i give you another example:

D=[61 45 54  23   51   41]

v=[ 61 23 41]

i want to remove  in D the element v


i want to remove element 61,23,41 ...not a position

ans=[45 54 51]   (i remove element [ 61 23 41] from [61 45 54  23   51  
41] and i don't want to change order element in D)



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

Doug Stewart-4
In reply to this post by Andreas Weber-6


On Sun, Feb 10, 2019 at 6:32 AM Andreas Weber <[hidden email]> wrote:
Am 10.02.19 um 09:15 schrieb turbofib:
> I want remove all element v....not only 1 element

I guess Doug thought that you would be able to modify his example and
replace 3 with v...



OK I know that, but I don't do student\s homework.
I did give you a very strong hint. and that is as far as I will go.
:-)





--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

turbofib




I already knew that to remove an element is done

d(element)=[]


it does not matter ... I'll do the usual without the vectorization





--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

Andreas Weber-6
In reply to this post by turbofib
Am 10.02.19 um 12:50 schrieb turbofib:
> i want to remove element 61,23,41 ...not a position
 > ans=[45 54 51]   (i remove element [ 61 23 41] from [61 45 54  23   51
 > 41])

So you should ask for this and create better examples:
Use setfiff

D=[61 45 54  23   51   41]
v=[ 61 23 41]

setdiff (D, v)
ans =

    45   51   54

-- Andy


Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

turbofib
thank for answer Andreas Weber-6

is not correct because i want to keep order

the answer correct is :

ans: 45 54 41




--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

Andreas Weber-6
Am 10.02.19 um 14:24 schrieb turbofib:
> is not correct because i want to keep order

Have you ever mentioned, that you want to keep the order?


Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

turbofib
yes i mentioned it in the post up  

i write
" ans=[45 54 51]   (i remove element [ 61 23 41] from [61 45 54  23   51  
41] and i don't want to change order element in D)
"


i don't want to change order element in D






--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: remove some element from array

Andreas Weber-6
Am 10.02.19 um 14:35 schrieb turbofib:
> yes i mentioned it in the post up

No, you didn't. And if you would have had a detailed look at my answer
and read the help for the used function, it would be easy for you to
keep the order.

-- Andy