Delete rows with certain values while keeping text in column
显示 更早的评论
I have a large table with data on traffic times and modes. A sample is given below:

Now I would like to remove all rows with a zero. This would be easy to perform on a matrix with something like this:
rows_to_remove = any(data==0, 2);
data(rows_to_remove,:) = [];
However, when I load this table as a matrix, the text data on the travel mode is converted into a numerical value that has no meaning.
How do I remove all rows with a zero while keeping the text in the 5th and 7th column?
5 个评论
Rogier Busscher
2017-6-8
Image Analyst
2017-6-8
"...load this table as a matrix..."??? What exactly did you do? Why not load it as a table with readtable()? And I'm not seeing any 0's in columns 5 and 7, just long strings with BIKE or GTC in them.
Rogier Busscher
2017-6-8
编辑:Rogier Busscher
2017-6-8
Image Analyst
2017-6-8
Are those two numbers separated by a comma a string? Or is that like some European countries that use a comma instead of a decimal point so they are really numbers, not strings? Can you attach your data file?
KSSV
2017-6-9
Attaching a snapshot of file, wont help. To get full help, attach the file.
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!