MATLAB: Select row from matrix based on month with datenum

datenumifmatrix

Hi. I have 2 matrices. A(12×1) contains month averages(Jan-Dec) and B(437×14) which contains daily values for specific days from 2007-2016. column 1 of matrix B contains datenum values. Is it possible to select a row from B if the value in column 9 is less than the corresponding monthly average from A.
For example: A(1,1) is for January and the average is 227.24. B(1,1) is 2/01/2006 and B(1,9) is 226.01. Then I would want to select that row and create a new matrix containing it as it is less than the corresponding monthly average.

Best Answer

Please attach file with your datas (A and B):
out = B(A(month(datetime(B(:,1),'InputFormat','yyyy-MM-dd'))) > B(:,9),:);