Removing zero values from an array
412 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alice Stembridge
am 14 Mai 2015
Kommentiert: Stephen23
am 21 Mär. 2022
I have an n x 1 array containing values. For exmaple A =
1
0
0
2
0
3
I was wondering if it was possible to create another array except without the zero values. For example
B =
1
2
3
1 Kommentar
Akzeptierte Antwort
Star Strider
am 14 Mai 2015
Using logical indexing, you can calculate ‘B’ in one line:
B = A(A~=0)
6 Kommentare
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!