Extract data from dataset with no nans and loop over columns
1 view (last 30 days)
Hi Matlab community,
I have run into a problem in my code and would very much appreciate your help.
I have three matrices of size 1825*52 with annual data. I want to extract the months January to june from the dataset when none of these three matrices have nan values and save it in three new matrices. I am able to make it work for one column, but then the code fails to loop for 52 columns. Rows are annual data from 2015 to 2019(no 31st dec data, so it has 1825 values) and columns are 52 different simulations.
Here is my code:
%Read only january to June with non nans for all years and all columns
for i=1:length(obs) %2015 to 2019 there is no 31st dec 2019 data so 1 value less
if month(time(i))>=1 && month(time(i))<=6 && isnan(obs(i,n))==0 && isnan(sim1(i,n))==0 && isnan(sim2(i,n))==0
Thanks in advance for your suggestions and help!
_ on 30 Nov 2021
I think, at least, these three lines:
should be modified to this:
since i is the row index you're checking and m is the row index of the good values only.
I'm not sure if this change is sufficient to make it work.