MATLAB: Access .txt and .csv, edit data, error statistics

csvedit datatxt

Hi guys!
I would appreciate your help on the following:
I have several files (attached you can find two of them) that contain measured (.txt) and simulated (.csv) hourly values for some meteorological variables. I am only interested in temperature and relative humidity. The simulated period run from 01-Jul-2019 to 30-Sep-2019, while for the observations, I have a couple of months more.
What I need to do is open both files for every station (here I attached only "Airport"), access the dates that both files contain data and produce graphs and error metrics.
Any ideas please?

Best Answer

A basic method for importing only the Temp and RH data into tables
filename = 'Airport.csv';
opts = detectImportOptions(filename);
opts.SelectedVariableNames = opts.SelectedVariableNames(16:17); % Columns 16 and 17 from .csv are temp and RH
data1 = readtable(filename,opts);
filename = 'Hourly Data Airport 2019.txt';
opts = detectImportOptions(filename);
opts.SelectedVariableNames = opts.SelectedVariableNames(2:3); % Columns 2 and 3 from .csv are temp and RH
data2 = readtable(filename,opts);