Elements of table equal to elements of another table
Mostra commenti meno recenti
Hi all!
I have a list of stations (see .txt) and a .csv (see attached) with several data. What I need to do is scan the entire .txt and for every station, eg. Airport, to go and scan column 14 of the .csv. If the station is the same, I want to do several things, eg. extract the date (column 2) and Temperature (column 15) every time Airport appears.
I tried with eq but it doesn't work.
list1 = rdir ('C:\Projects\LIFE ASTI\C.3\C.3\Weather station data\from desktop\Obs. data 4 Keppas\');
wrfdir = 'C:\Projects\LIFE ASTI\C.3\C.3\Weather station data\from desktop\2019 run\Thess\*.csv';
stations = readtable('C:\Projects\LIFE ASTI\C.3\C.3\Weather station data\from desktop\Stations coordinates.txt');
output_path='C:\Projects\LIFE ASTI\C.3\C.3\Weather station data\from desktop\OutputSimulations';
WRF_Data = readtable('C:\Projects\LIFE ASTI\C.3\C.3\Weather station data\from desktop\2019 run\Thess\THESS_Temp.csv');
% Variables
vars={'Temperature'; 'Relative humidity'};
years = {'2015'; '2019'};
varunits={'Celsius'; '%' };
%Starting loop for all files
for i=1:size(stations,1)
for k = 1:size(WRF_Data.Station,1)
if eq(stations(i,1) , WRF_Data.Station(k,1))
KEEP TEMPERATURE OR WHATEVER...
end
end
end
Risposta accettata
Più risposte (1)
Philippe Lebel
il 24 Gen 2020
Modificato: Philippe Lebel
il 24 Gen 2020
Here you go:
I loop over all station names and check where in the data table i find these names. I generate a boolean index in order to fetch data from the table and store them in a structure.
clear
stations = readtable('\Stations coordinates.txt');
WRF_Data = readtable('\THESS_Temp.csv');
%Starting loop for all files
for i=1:size(stations,1)
WRF_Data_station_mask = ismember(WRF_Data(:,14),stations(i,1));
sorted_values(i).name = char(stations{i,1});
sorted_values(i).temps = WRF_Data(WRF_Data_station_mask,15);
end
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!