If I have an array with values and then another array with each value's category, how would I remove values with certain categories?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Kylenino Espinas
am 21 Okt. 2020
Bearbeitet: drummer
am 21 Okt. 2020
%For example if
Data = (1.2, 3.4, 6.7)
Category = (1, 4, 1)
%How would I remove 1.2 and 6.7 since they each have a category of 1?
0 Kommentare
Akzeptierte Antwort
drummer
am 21 Okt. 2020
Bearbeitet: drummer
am 21 Okt. 2020
First, your notation for array is misguided.
notation for arrays is [ ].
If you want only remove, reducing the size of your Data array, try this:
Data = [1.2, 3.4, 6.7];
Cat = [1, 4, 1];
Data(Cat == 1) = [];
Your output will be:
Data =
3.4
Accept the answer if that helps.
Cheers
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!