Create and update table into loop

조회 수: 6 (최근 30일)
Daphne PARLIARI
Daphne PARLIARI 2021년 3월 29일
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개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by