Problem with retime function

조회 수: 2 (최근 30일)
yogan Sganzerla
yogan Sganzerla 2021년 8월 5일
댓글: Peter Perkins 2021년 8월 5일
Hello,
I am trying to use retime in my Table however I am facing one problem.
As you can see in the Image above, this is my time vector and from 2nd July on 12:00 bis 8th July 12:00 I don't have data (this is why is a vertical line)
Well, I would like to fill in this vector with Zeros. Fro that I used the following code:
TT2 = retime(theRawData, newTimes, 'Constant',0)
where theRowData is my origical table without data from 2nd bis 8th
the newTimes is a vector for that I created with all the time even where I don't have data.
I am attachin the variables as well.
The idea it to fill in with zeros just in the time where we don't have data, however from 02 july 12:00 until the end of my vector , I am receiving zeros.
Thanks in advance.
  댓글 수: 1
Peter Perkins
Peter Perkins 2021년 8월 5일
Yogan, you have two problems.
First, you are not specifying a method for the retime. The default is fillwithmissing, and that's what it's doing.
Second, you new times are almost all different than the time vector in theRawData. So you are creating a new timetable with a different time vector, almost all filled with NaN.
>> d = newTimes(1:5) - theRawData.theDatetimevector(1:5);
>> d.Format = 's'
d =
5×1 duration array
0 sec
0 sec
9.7656e-06 sec
9.7656e-06 sec
9.5215e-06 sec
>> newTimes.Format = 'uuuu-MM-dd HH:mm:ss.SSSSSSSSS';
>> theRawData.theDatetimevector.Format = 'uuuu-MM-dd HH:mm:ss.SSSSSSSSS';
>> newTimes(1:15),theRawData.theDatetimevector(1:5)
ans =
5×1 datetime array
2021-07-02 05:01:00.000000000
2021-07-02 05:01:01.016952636
2021-07-02 05:01:02.033905273
2021-07-02 05:01:03.050857910
2021-07-02 05:01:04.067810546
ans =
5×1 datetime array
2021-07-02 05:01:00.000000000
2021-07-02 05:01:01.016952636
2021-07-02 05:01:02.033895507
2021-07-02 05:01:03.050848144
2021-07-02 05:01:04.067801025

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

답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by