Create and update table into loop
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!