Connect correct temperature to another table based on time
Show older comments
I want to connect two tables with each other. I have one table A:
A = [13-aug-2020, 14-aug-2020, 15-aug-2020], [13.8, 12.2, 8.5];
B = [14-aug-2020, 14-aug-2020, 13-aug-2020], [155, 203, 200];
Now I want to combine those two tables with each other based on time like this:
B = [14-aug-2020, 14-aug-2020, 13-aug-2020], [155, 203, 200], [12.2, 12.2, 13.8];
Anyone who can help me with this?
I read the tables like this at the moment
clear all; close all; clc;
check = dir('*.xls');
list = [];
for i = 3
opts = spreadsheetImportOptions("NumVariables", 3);
% Specify sheet and range
opts.Sheet = "Sheet1";
opts.DataRange = "A2:C367";
% Specify column names and types
opts.VariableNames = ["Aug2020", "VarName2", "Temp"];
opts.VariableTypes = ["datetime", "double", "double"];
% Specify variable properties
opts = setvaropts(opts, "Aug2020", "InputFormat", "");
% Import the data
weatherYear = readtable("/Users/diontheunissen/Documents/Smart_Driver/RawData/weatherYear.xlsx", opts, "UseExcel", false);
Date = datetime(weatherYear.Aug2020);
weatherYear.Aug2020 = Date;
opts = spreadsheetImportOptions("NumVariables", 10);
% Specify sheet and range
opts.DataRange = "A2:J414";
% Specify column names and types
opts.VariableNames = ["UitgevoerdDoor", "Rapport", "ActiviteitType", "Lat", "Long", "Starttijd", "Duurms", "KilometerstandBegin", "GeredenAfstand", "TotaalVerbruik"];
opts.VariableTypes = ["categorical", "string", "string", "string", "string", "datetime", "double", "double", "double", "double"];
% Specify variable properties
opts = setvaropts(opts, "Rapport", "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["UitgevoerdDoor", "Rapport", "ActiviteitType", "Lat", "Long"], "EmptyFieldRule", "auto");
opts = setvaropts(opts, "Starttijd", "InputFormat", "");
% Import the data
name = fullfile(check(i).folder, check(i).name);
Ritten = readtable(name, opts, "UseExcel", false);
Datum = datetime(Ritten.Starttijd);
Datum.Format = 'dd-MMM-yyy';
Ritten.Starttijd = Datum;
% pos=find(ismember(Datum,Date));
% for m = 1:length(Datum)
% for np = 1:length(Date)
% n = string(Datum(m));
% weatherYear.Temp(n)
% end
% end
end
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!