How to find a gap in a table

조회 수: 8 (최근 30일)
Carolina
Carolina 2023년 2월 5일
댓글: Image Analyst 2023년 2월 5일
Hi. I am doing a project and need to analyze a long series of data. In this data I have dates and times, however I need to find the rows of missing times and delete the next data, I will explain with an example.
Date Hour
10-02-2013 00:00
10-02-2013 01:00
10-02-2013 02:00
10-02-2013 03:00
10-02-2013 05:00
10-02-2013 06:00
10-02-2013 07:00
I have hours from 00 to 23. In this case, for example, the hour relative to 4 a.m. is missing, how do I identify these gaps over several columns and delete the next record?
  댓글 수: 1
the cyclist
the cyclist 2023년 2월 5일
The difficult part of this is probably not the MATLAB coding; it's defining the exact rule to be used to identify the gaps. (I don't mean the coding of the rule, just the explanation of the exact rule.)
Can upload the data (or a representative subset), and tell us the exact rule?

댓글을 달려면 로그인하십시오.

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 2월 5일
If understood your qyestion correctly, you are trying to remove the rows of data in any row there is a missing data. If so, use:
ismissing() or isnan(), and assign those row to [ ]. E.g.:
D = readtable('D_tab.txt'); % Sample data is attached
D(ismissing(D{:,2}),:)=[]
  댓글 수: 1
Image Analyst
Image Analyst 2023년 2월 5일
In his example 4:00 was not even in the table at all, so ismissing won't detect it. I think you need to use diff

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by