delete specific rows in a table
Show older comments
Hi guys, I need your help.
See attached table. I would like to delete the rows in which the first column (time) have a decimal number in it (keep only those rows where the time is an integer number)
After that I would like to delete the rows where the time is repeated and keep only the first one. For example, if there are 3 rows with time 5, we should only keep the top row.
Any help with that?
Many thanks
Accepted Answer
More Answers (1)
Image Analyst
on 17 Sep 2021
Try this:
allData = readmatrix('A.xlsx');
times = allData(:, 1);
% Find out where time is a pure integer
goodRows = times - round(times) == 0;
% Extract good rows
times = times(goodRows);
allData = allData(goodRows, :);
1 Comment
Image Analyst
on 17 Sep 2021
Basically same as the Cyclist. I was working on mine while he was uploading his.
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!