fitlm, how to use two datasets with identical size and timestamps

조회 수: 4 (최근 30일)
Dharmesh Joshi
Dharmesh Joshi 2022년 9월 20일
댓글: Dharmesh Joshi 2022년 10월 10일
Hi
I have two data sets. Each dataset has the sensor values and a timestamp.
I would like to use fitlm to determin a linear function between both these sets of data, but the data used in this function should only be data that has timestamp in both two data sets, to that when data is being compared it at the same timestamp.
The issue is that a certain periods the dataset might have some data samples missing a certain time stamps.
This is my current code.
ref_timetable_time=[ref_data_timestamp]';
ref_timetable_ug=[ref_data_sensordata]';
ref_timetable = timetable(ref_timetable_time,ref_timetable_ug);
timerperiod_Ref=ref_timetable(timerperiod,:);
timetable_time=[live_t]';
timetable_ug=[no2_ppb];
timetable_ug = timetable(timetable_time,timetable_ug);
timerperiod_ug=timetable_ug(timerperiod,:);
hourlyaveraged_no2_data = retime(timerperiod_ug,'hourly','mean');
%model sensor data to ref data
inModels{k} = fitlm( timerperiod_Ref.ref_timetable_ug, hourlyaveraged_no2_data.timetable_ug, "linear", "VarNames", ["Ref Data", "SensorValue"] );
What can be done so that dataset are equal in both size and timestamps?
Thank You
  댓글 수: 9
KSSV
KSSV 2022년 9월 22일
To find the missing values, you can use either interp1 or fillmissing.

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

답변 (0개)

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by