フィルターのクリア

Error using interp1

2 ビュー (過去 30 日間)
Veerle Kohlen
Veerle Kohlen 2020 年 12 月 7 日
コメント済み: Star Strider 2020 年 12 月 8 日
Hi all,
I'm trying to interpolate my data set using interp1.
My data set looks something like:
tympanic.nw1.Time =
'10:04:48'
'10:04:49'
'10:04:50'
'10:04:51'
'10:04:52'
'10:04:53'
tympanic.nw1.Temperature =
35.3000000000000
35.3000000000000
35.4000000000000
35.4000000000000
35.4000000000000
35.3000000000000
35.3000000000000
I used the following code:
% Tympanic Temp
t1 = tympanic.nw1.Time(1,1); t2 = tympanic.nw1.Time(end,1); t = t1:seconds(1):t2; t = t.';
tympanic.nw1.Temperature = interp1(tympanic.nw1.Time, tympanic.nw1.Temperature, t);
tympanic.nw1.Time = t;
Matlab gives the following error: Error using griddedInterpolant. Sample points must be unique and sorted in ascending order. Can someone explain me how to solve this problem? I already tried using the function unique, but that didn't solve my problem.
  1 件のコメント
Rik
Rik 2020 年 12 月 7 日
What data type is your time array?

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2020 年 12 月 7 日
編集済み: Star Strider 2020 年 12 月 7 日
Veerle Kohlen —
You likely need to put your data into a timetable array, then use the retime function. That would likely be the easiest way to do it.
Example —
tympanic.nw1.Time = ['10:04:48'
'10:04:49'
'10:04:50'
'10:04:51'
'10:04:52'
'10:04:53'];
tympanic.nw1.Temperature = [35.3000000000000
35.3000000000000
35.4000000000000
35.4000000000000
35.4000000000000
35.3000000000000];
T1 = table(tympanic.nw1.Time, tympanic.nw1.Temperature);
T1.Var1 = datetime(T1.Var1, 'InputFormat','HH:mm:ss', 'Format','HH:mm:ss');
TT1 = table2timetable(T1);
TT1rt = retime(TT1, 'secondly','TimeStep',1);
EDIT — (7 Dec 2020 at 16:36)
Added the example.
  2 件のコメント
Veerle Kohlen
Veerle Kohlen 2020 年 12 月 8 日
Thank you!
Star Strider
Star Strider 2020 年 12 月 8 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by