How to delect the zero values in table
34 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chao Zhang
am 24 Mai 2021
Kommentiert: Chao Zhang
am 24 Mai 2021
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/628863/image.png)
There is a table in matlab, I want to know how to delete the entire row with zero values?
Many thanks in advance.
0 Kommentare
Akzeptierte Antwort
the cyclist
am 24 Mai 2021
If all of the table entries are numeric, then this will work:
% Create an example input table
x = [0; 1; 0; 2];
y = [0; 1; 0; 2];
z = [0; 0; 0; 0];
tbl = table(x,y,z)
% Identify rows with all zeros, by first converting to numeric
rowsToDelete = all(table2array(tbl)==0,2);
% Delete the rows
tbl(rowsToDelete,:) = []
Weitere Antworten (1)
Fangjun Jiang
am 24 Mai 2021
Bearbeitet: Fangjun Jiang
am 24 Mai 2021
a=[1 2 3;0 0 0 ; 1 0 2];
index=all(a==0,2);
a(index,:)=[];
0 Kommentare
Siehe auch
Kategorien
Mehr zu Tables 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!