[Scilab-users] Removing elements of one vector from another vector
Samuel Gougeon
sgougeon at free.fr
Sat Aug 18 18:21:22 CEST 2018
Hello,
Le 16/08/2018 à 16:55, Izabela Wójcik-Grząba a écrit :
> Hello,
>
> Is there any simple way to remove from one vector elements which are
> in another vector. For example:
> a=[1 2 3 4 5 6 7 8]
> b=[1 3 5]
> resulting vector: c=[2 4 6 7 8].
> I wonder if this can be done without a "for" loop.
Yes. For the simplest query:
--> setdiff(a,b)
ans =
2. 4. 6. 7. 8.
If "a" has duplicates and you want to remove b values value-per-value :
Example:
a = [1 2 3 3 4 5 5 5 6 ]
b=[1 3 5]
and you expect [2 3 4 5 5 6]
=> things are different
Samuel
More information about the users
mailing list