필터 지우기
필터 지우기

Remove repeat values in a text file

조회 수: 5 (최근 30일)
Joseff Saunders
Joseff Saunders 2018년 12월 7일
댓글: Joseff Saunders 2018년 12월 7일
Hello all, below is a section of data from a weather station, the weather station is supposed to record once a minute, however, some have duplicate minute recordings. For me to analyse it I need to remove the duplicate readings, the only way of identifying the duplicate readings is by the minute column (i.e. two recordings from minute 1 etc.) Any ideas as to a solution?
day month year hour minute temperature
25 1 2017 1 1 1.5
25 1 2017 1 1 5.9
25 1 2017 1 2 5.4
25 1 2017 1 3 5.2
25 1 2017 1 4 5.1
25 1 2017 1 5 5.5
25 1 2017 1 5 5.6

채택된 답변

Akira Agata
Akira Agata 2018년 12월 7일
Assuming your data is stored in table variable T
>> T
T =
7x6 table
day month year hour minute temperature
___ _____ ____ ____ ______ ___________
25 1 2017 1 1 1.5
25 1 2017 1 1 5.9
25 1 2017 1 2 5.4
25 1 2017 1 3 5.2
25 1 2017 1 4 5.1
25 1 2017 1 5 5.5
25 1 2017 1 5 5.6
Then, unique rows can be simply extracted by using unique function, like:
[~,idx] = unique(T(:,{'day','month','year','hour','minute'}),'rows');
T = T(idx,:);
  댓글 수: 1
Joseff Saunders
Joseff Saunders 2018년 12월 7일
Thank you this worked well, however the issue I am having now is that some data from particular minutes is missing (i.e. it wasn't recorded in the first place), as there are supposed to be 60 minutes for each hour, is there a way of testing to see which minutes are missing?

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

추가 답변 (1개)

ahmed nebli
ahmed nebli 2018년 12월 7일
i suggest you need to write an if condition on the minute vector exemple : if minute(n-1) == minute(n) then you delete the row n from the table.

카테고리

Help CenterFile Exchange에서 Weather and Atmospheric Science에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by