Hello everyone,
I have a big table (25560 x 12) which includes data for 71 stations on a monthly bases from 30 years. I want to extract data from it based on the names (from station_name column) and month names (from date column). I want to save all results on the workspace as separate tables.
I searched a lot and write this code that does what I want for 2 stations but unfortunately, I should write it for all 71 stations (change names by hand) that is so time-consuming process. I want to ask if anyone could help me to do it using for loop or something.
%Read one of stations
Ahvaz_table = stations(stations.station_name == "Ahvaz", :);%extract it month by month with name of month infront of station name:
Ahvaz_Jan = Ahvaz_table(month(Ahvaz_table.date) == 1, :)Ahvaz_Feb = Ahvaz_table(month(Ahvaz_table.date) == 2, :)Ahvaz_Mar = Ahvaz_table(month(Ahvaz_table.date) == 3, :)Ahvaz_Apr = Ahvaz_table(month(Ahvaz_table.date) == 4, :)Ahvaz_May = Ahvaz_table(month(Ahvaz_table.date) == 5, :)Ahvaz_Jun = Ahvaz_table(month(Ahvaz_table.date) == 6, :)Ahvaz_Jul = Ahvaz_table(month(Ahvaz_table.date) == 7, :)Ahvaz_Aug = Ahvaz_table(month(Ahvaz_table.date) == 8, :)Ahvaz_Sep = Ahvaz_table(month(Ahvaz_table.date) == 9, :)Ahvaz_Oct = Ahvaz_table(month(Ahvaz_table.date) == 10, :)Ahvaz_Nov = Ahvaz_table(month(Ahvaz_table.date) == 11, :)Ahvaz_Dec = Ahvaz_table(month(Ahvaz_table.date) == 12, :)%go to next station
Fasa_table = stations(stations.station_name == "Fasa", :);%extract it month by month with name of month infront of station name:Fasa_Jan = Fasa_table(month(Fasa_table.date) == 1, :)Fasa_Feb = Fasa_table(month(Fasa_table.date) == 2, :)Fasa_Mar = Fasa_table(month(Fasa_table.date) == 3, :)Fasa_Apr = Fasa_table(month(Fasa_table.date) == 4, :)Fasa_May = Fasa_table(month(Fasa_table.date) == 5, :)Fasa_Jun = Fasa_table(month(Fasa_table.date) == 6, :)Fasa_Jul = Fasa_table(month(Fasa_table.date) == 7, :)Fasa_Aug = Fasa_table(month(Fasa_table.date) == 8, :)Fasa_Sep = Fasa_table(month(Fasa_table.date) == 9, :)Fasa_Oct = Fasa_table(month(Fasa_table.date) == 10, :)Fasa_Nov = Fasa_table(month(Fasa_table.date) == 11, :)Fasa_Dec = Fasa_table(month(Fasa_table.date) == 12, :)% go to next station
...
Thank you all.
I attached my whole table.
Best Answer