How removing elements from vector?

7 visualizzazioni (ultimi 30 giorni)
huda nawaf
huda nawaf il 9 Ago 2022
Commentato: huda nawaf il 10 Ago 2022
Hello,
How removing some elements from a long vector.
For example:
c=[1 2 3];
z=[10 9 1 4 11 2 6 3];
How removing c from z?
Tjanks in advance

Risposta accettata

Stephen23
Stephen23 il 9 Ago 2022
Modificato: Stephen23 il 9 Ago 2022
c = [1,2,3]
c = 1×3
1 2 3
z = [10,9,1,4,11,2,6,3]
z = 1×8
10 9 1 4 11 2 6 3
x = setdiff(z,c,'stable')
x = 1×5
10 9 4 11 6
or
z(ismember(z,c)) = []
z = 1×5
10 9 4 11 6

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by