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

18 views (last 30 days)
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)

Answers (1)

Mathieu NOE
Mathieu NOE on 4 Oct 2021
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 Comments

Sign in to comment.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!