How to synchronise two time series data with different sampling time in MATLAB?

16 次查看(过去 30 天)
There are two sensor measured power and temperature and they have 4 mintutes sampling time difference. I want to synchronise time of power and temperature sensor data. How can I synchrnoise in csv data file? it because around 9440 obeservation the time difference between two devices become 10 minutes which created problem graph plotted. how can I use interp1 to sychnronise two different time data?
interp1(x,v,xq)

回答(1 个)

Mathieu NOE
Mathieu NOE 2021-10-4
hello
see my suggeston below
the new common time vector is sampled with only N = 100 here , but you can adjust this to your own needs
clc
clearvars
T =readtable('sample file.xlsx','Format','auto');% Sr no_Temperature_sensor Sr no_Power_sensor Time_Temperature_sensor Time_Power_sensor
Time_Temperature_sensor = str2double(T.Time_Temperature_sensor);
Time_Power_sensor = str2double (T.Time_Power_sensor);
Temperature_sensor = T.SrNo_Temperature_sensor;
Power_sensor = T.SrNo_Power_sensor;
% common time vector
common_time_min = max(min(Time_Temperature_sensor),min(Time_Power_sensor));
common_time_max = min(max(Time_Temperature_sensor),max(Time_Power_sensor));
N = 100;
common_time_vector = linspace(common_time_min,common_time_max,N);
% interpolate both data sets on common time vector
Temperature_sensor2 = interp1(Time_Temperature_sensor,Temperature_sensor,common_time_vector);
Power_sensor2 = interp1(Time_Power_sensor,Power_sensor,common_time_vector);
figure
plot(common_time_vector,Temperature_sensor2,common_time_vector,Power_sensor2);
  3 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by