Incomplete time series, how to fill in NaN in data column?

조회 수: 4 (최근 30일)
Anne Sofie Søndergaard
Anne Sofie Søndergaard 2016년 2월 1일
댓글: Ingrid 2016년 2월 1일
Hi
I have a time series consisting of date, time, longitude and latitude. Due to errors there are gaps in my date/time but the data just continue at the next date when a position is registered. What I want is to get a complete time serie (for a year) with NaN values in Long and Lat columns when a position is missing. The data is registerede (when no errors) every three hours, so I have constructed a Date/Time vector using datenum, with values every three hours, so 2920 values (8*365) for a whole year. Now I want to put in NaN in my Long and Lat on the times that matches the errors - how can I do that? I have looked at similar questions in here, but they all seem to be a bit different or just wanting to fill in NaN in the time column.
Here is a couple of lines from my data:
Date, Time, Lat, Long, Voltage(V)
01-30-2014,18:00:33,73.09214,-54.11712,N/A
01-30-2014,21:00:33,73.09213,-54.11710,N/A
01-31-2014,00:00:34,73.09212,-54.11719,N/A
02-24-2014,00:00:33,73.09113,-54.12063,N/A
02-24-2014,03:00:33,73.09112,-54.12063,N/A
02-24-2014,06:00:33,73.09113,-54.12068,N/A
So what i want is to fill in the dates from 02-01-2014 to 02-23-2014 with date and time (I have done that) and then fill in NaN in the Long and Lat columns.
Would be gratefull for help...

채택된 답변

Ingrid
Ingrid 2016년 2월 1일
you could just first create a NaN matrix and then fill in your original values at the dates that you have them available
newData = nan(length(timeVector),2);
[~,Ia,Ib] = intersect(round(originalData(:,1:2)*100),round(timeVector*100));
newData(Ib,:) = originalData(Ia,3:4);
  댓글 수: 2
Anne Sofie Søndergaard
Anne Sofie Søndergaard 2016년 2월 1일
Thank you so much, it works, pretty simple, but i'm relatively new in Matlab.. Thanks....
Ingrid
Ingrid 2016년 2월 1일
If this helped you, could you please accept the answer so that it is marked as solved so other people know this no longer requires an answer. Thank you

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cartesian Coordinate System Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by