Find duplicate of first xx entries and average associated values

조회 수: 2 (최근 30일)
Minh Phuong Truong
Minh Phuong Truong 2022년 7월 7일
댓글: Minh Phuong Truong 2022년 7월 7일
Hi all,
I have 140000x3 array data (time, lat, lon). The time column looks like [2019/12/18 上午 07:53:00]. I would like to get the mean lon and lat of several points in the same minute, like [2019/12/18 上午 07:53].
Thanks
  댓글 수: 5
Chris Burschyk
Chris Burschyk 2022년 7월 7일
You could load the data into a timetable and then use something like
T = readtimetable("YourFile.csv");
YourYear = 2019;
YourMonth = 1;
YourDay = 8;
YourHour = 8;
YourMin = 41:
mean(T{T.SYSTEMTIME.Year == YourYear & T.SYSTEMTIME.Month == YourMonth & T.SYSTEMTIME.Day == YourDay & T.SYSTEMTIME.Hour == YourHour & T.SYSTEMTIME.Minute == YourMinute, "LONGITUDE" })
Maybe not the prettiest way to do, but you could use it with a loop as well.

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

답변 (1개)

KSSV
KSSV 2022년 7월 7일
Read the file into MATLAB using readtable.
See to it that your dates i.e. thirs column is in datetime class. For this read about datetime, datestr, datenum.
Find the duplicates using unique. By using the indices you can get the required mean.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by