I need some help creating one code to extract some rows with certain conditions. I have a 3D matrix (latitude,longitude,time(15000 values,1 value a day)) called wind_speed. I have too, an Excel file, with 16 specific latitudes and longitudes that I need specifically study.
I need to calculate the wind speed by year but I have difficulty with that extraction.
All I want is 16 (one for each set of lat/lon) new 2D matrixes that give me the years in the rows with 365 or 366 days, one day by line.
I've already specified the first day of the sample with:
N0=datenum(1979,1,1);
and extract my 16 points from an Excel file with:
[num,txt,raw] = xlsread('Coordinates.xlsx');
latPoint=squeeze(num(:,2));
lonPoint=squeeze(num(:,1));
for ii=1:16
ilon = find(longitude(:,1)==lonPoint(ii));
ilat = find(latitude(:,1)==latPoint(ii));
wind_speed_points(:,ii) = squeeze(wind_speed(ilon,ilat,:));
end
So far, so good. I've already run this and works to found in the matrix wind_speed_points the values correspondent to a specific year
iyear=0;
for i=1:nt; %%nt=lenght(time)
year = str2double(datestr(N0+i-1,'yyyy'));
if(year == 1979)
iyear=iyear+1;
for ii=1:16
w_speed_new(iyear,ii) = squeeze(wind_speed_points(i,ii));
end
end
end
I will have a matrix 365x16 that represent 365 days for each set lon/lat extracted from the Excel. But is not what I want. All I want is 16 matrix (one for each set) with lets say 22 rows (1979,1980,1981,1982,1983...1999,2000) and 365 or 366 lines. To create a matrix with same size the final value of each vector with 365 lines could be zero.