How to create parametric table names
Afficher commentaires plus anciens
I have a table 59x7 named as 'all_cities'. (Number of rows may change according to avaible data)
I exract the values according to station name. Second column is the station names(Istasyon_Adi).
names_table=all_cities{:,2}; %exract the column where station names are stored
station_names=unique(names_table); % determine the station names one by one
Then, i create unique table containing all other columns/data for each station seperately.
N_station=size(station_names,1); % Number of stations
for i=1:N_station
station_name=station_names(i,1);% determine the station to consider for current loop
station_data=all_cities(all_cities.Istasyon_Adi==station_name,3:7); %create seperate table for considered station
end
But this loop deletes the previous table.
I need to keep all tables created within this loop seperately. Something like this;
N_station=size(station_names,1); % Number of stations
for i=1:N_station
station_name=station_names(i,1);% determine the station to consider for current loop
station_data(i)=all_cities(all_cities.Istasyon_Adi==station_name,3:7); %create seperate table for considered station
end
After that, i need to save the all tables created in the loop with file names which are the same as station name(station_name.xlsx)
N_station=size(station_names,1); % Number of stations
for i=1:N_station
station_name=station_names(i,1);% determine the station to consider for current loop
station_data(i)=all_cities(all_cities.Istasyon_Adi==station_name,3:7); %create seperate table for considered station
writetable(station_data(i),'station_name.xlsx');% write this table to excel file, assign file names as station name considered for this loop
end
1 commentaire
Walter Roberson
le 23 Oct 2019
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!