Create and update table into loop
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello guys!
I would appreciate your expertise on this:
I have a loop that reads and does several things on a series of input data. It goes like this
output_path = ('C:\PhD\Validation Natalia\Output');
obsdir = 'C:\PhD\Validation Natalia\Meteo data\Daily Data\';
wrfdir = 'C:\PhD\Validation Natalia\WRF\Daily Data\';
list1 = rdir ('C:\PhD\Validation Natalia\Meteo data\Daily Data\');
stations = readtable('C:\PhD\Validation Natalia\stations_Natalia.csv');
tdaily=datetime(2015,1,1):days(1):datetime(2015,12,31);
for i=1:size(stations,1)-1
var=('Temperature'); varunits=('C');
name = stations( i, 1 );
name.(1);
namestr = char(name.(1));
indx = strfind (list1, namestr) ;
for j = 1:size(indx, 1)
if (indx{j,1}>0)
if (strfind(list1{j,1}, 'txt') > 0)
obsfile = [obsdir, 'Daily_Obs_',namestr,'.txt']
Obs_Data = readtable(obsfile);
wrffile = [wrfdir, 'Daily_WRF_', namestr, '.txt']
WRF_Data = readtable(wrffile);
All=table(WRF_Data.Date_UTC, WRF_Data.Temp, Obs_Data.Temp);
All.Properties.VariableNames{1} = 'Date_UTC'; All.Properties.VariableNames{2} = 'WRF_Temp';
All.Properties.VariableNames{3} = 'Obs_Temp';
end
end
end
end
As you can see, I have data from 8 stations that are being processed. What I want to do is to store all the All tables into one separate table (e.g. Data_All_Stations), every time the i loop runs again. As a result, Data_All_Stations will have 1 Column titled Date_UTC, and 2 columns for each station (WRF_Temp and Obs_Temp with station name).
Is there a way to do so? thank you in advance!
PS. I am on Matlab 2019a.
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!