Extract data by more indexes

1 view (last 30 days)
Valerio Gianforte
Valerio Gianforte on 9 Mar 2020
Edited: Valerio Gianforte on 10 Mar 2020
Hi Everyone,
I made a code that extracts the data between two years and every six hours. My data starts from 1979 and arrives 2019 and for each day I have 23 values, with the code below I would obtain a sheet data that starts from 1985 and arrives 2005 and for each days have 4 values (1 value every six hours). The question is, the index that I wrote is right to do the operation above?
format long g;
folderData = 'D:\Valerio\data\ERA_5';
filePattern = fullfile(folderData, '*.xlsx');
xlsFiles = dir(filePattern);
nFiles = length(xlsFiles);
for ii = 1:nFiles
filename = fullfile(xlsFiles(ii).folder, xlsFiles(ii).name);
files{ii} = xlsread(filename);
end
DIR = files(1);
Hs = files(2);
time = files(3);
Tp = files(4);
U_wind = files(5);
V_wind = files(6);
YYMMDD = cell2mat(time);
Years = YYMMDD(:,1);
Month = YYMMDD(:,2);
Days = YYMMDD(:,3);
HH = YYMMDD(:,4);
H_s = Hs{:,1};
T_p = Tp{:,1};
dir = DIR{:,1};
uwind = U_wind{:,1};
vwind = V_wind{:,1};
index = find(((HH == 0)|(HH == 6)|(HH == 12)|(HH == 18))&(Years >= 1985 & Years <= 2005));
YY = Years(index);
MM = Month(index);
DD = Days(index);
hh = HH(index);
Hs1 = H_s(index);
Tp1 = T_p(index);
Dir1 = dir(index);
  2 Comments
Valerio Gianforte
Valerio Gianforte on 10 Mar 2020
Edited: Valerio Gianforte on 10 Mar 2020
I'm attacching the data. this is one of the files that has the same format of the other.

Sign in to comment.

Answers (0)

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!