I am trying to put a large number of data set which is in as a matrix to certain bins. But I get zeroes in my binned data set and I don't know what to do. My program is a bit long. Once I print one data set I get random zeros everywhere in the data set. I will be grateful if anyone can help me.
clc;clear all;ncdisp('at.nc')T = ncread('at.nc','T',[1 1], [Inf Inf], [1 1]);year= ncread('at.nc','year',[1],[Inf], [1]);month= ncread('at.nc','month',[1], [Inf], [1]);alt= ncread('at.nc','altitude',[1], [Inf], [1]);day= ncread('at.nc','day',[1],[Inf], [1]);flag= ncread('at.nc','quality flag',[1 1], [Inf Inf], [1 1]);for i=1:32025 x(i)=year(i); d(i)=day(i); m(i)=month(i);endfor i=1:32025 if ((m(i)==1 )&& (d(i)>=0.5) && (d(i)<=15.25)) L(i)=1; elseif d(i)>=15.26 && d(i)<=30.5 && m(i)==1 L(i)=2; elseif (d(i)==31 && m(i)==1) || (d(i)<=14.75 && m(i)==2) L(i)=3; elseif (d(i)>=14.76 && m(i)==2) || (d(i)<=1.5 && m(i)==3) L(i)=4; elseif (d(i)>=16.5 && d(i)==31 && m(i)==3) L(i)=5; elseif (d(i)>=16.5 && m(i)==3) || (d(i)<=31 && m(i)==3) L(i)=6; elseif (d(i)==1 && m(i)==4) || (d(i)<=15.75 && m(i)==4) L(i)=7; elseif (d(i)>=15.75 && m(i)==4) || (d(i)==30 && m(i)==4) L(i)=8; elseif (d(i)>=1 && m(i)==5) || (d(i)<=16.75 && m(i)==5) L(i)=9; elseif (d(i)>=16.25 && m(i)==5) || (d(i)==31 && m(i)==5) L(i)=10; elseif (d(i)==1 && m(i)==6) || (d(i)<=15.75 && m(i)==6) L(i)=11; elseif (d(i)>=15.25 && m(i)==6) || (d(i)==30 && m(i)==6) L(i)=12; elseif (d(i)==1 && m(i)==7) || (d(i)<=16.75 && m(i)==7) L(i)=13; elseif (d(i)>=16.25 && m(i)==7) || (d(i)==30 && m(i)==7) L(i)=14; elseif (d(i)==1 && m(i)==8) || (d(i)<=15.75 && m(i)==8) L(i)=15; elseif (d(i)>=15.75 && m(i)==8) || (d(i)==31 && m(i)==8) L(i)=16; elseif (d(i)>=0.5 && m(i)==9) || (d(i)<=15.75 && m(i)==9) L(i)=17; elseif (d(i)==30 && m(i)==9) || (d(i)<=15.75 && m(i)==9) L(i)=18; elseif (d(i)==1 && m(i)==10) || (d(i)<=15.75 && m(i)==10) L(i)=19; elseif (d(i)<=31 && m(i)==10) || (d(i)>=15.75 && m(i)==10) L(i)=20; elseif (d(i)==1 && m(i)==11) || (d(i)<=15.75 && m(i)==11) L(i)=21; elseif (d(i)==30 && m(i)==11) || (d(i)>=15.75 && m(i)==11) L(i)=22; elseif (d(i)==1 && m(i)==12) || (d(i)<=15.75 && m(i)==12) L(i)=23; elseif (d(i)==31 && m(i)==12) || (d(i)>=15.75 && m(i)==12) L(i)=24; else L(i) endendn=0;for i=1:120 for m=1:24 w4(i,m)=1; w5(i,m)=1; w6(i,m)=1; w7(i,m)=1; w8(i,m)=1; w9(i,m)=1; w10(i,m)=1; w11(i,m)=1; w12(i,m)=1; w13(i,m)=1; endendfor j=1:32025if (x(j)==2004) for i=1:120 if (flag(i,j)<=2)&& ((T(i,j))>0)&&(~isnan(T(i,j))) E4(i,L(j),w4(i,L(j)))= T(i,j); E4(i,L(j),w4(i,L(j))); w4(i,L(j))= w4(i,L(j))+1; end endelseif (x(j)==2005) if (flag(i,j)<=2)&& ((T(i,j))>0)&&(~isnan(T(i,j))) for i=1:120 E5(i,L(j),w5(i,L(j)))= T(i,j) w5(i,L(j))= w5(i,L(j))+1; end endelseif (x(j)==2006) if(flag(i,j)<=2) && ((T(i,j))>0)&&(~isnan(T(i,j))) for i=1:120 E6(i,L(j),w6(i,L(j)))= T(i,j); w6(i,L(j))= w6(i,L(j))+1; end endelseif (x(j)==2007) if(flag(i,j)<=2)&& ((T(i,j))>0)&&(~isnan(T(i,j))) for i=1:120 E7(i,L(j),w7(i,L(j)))= T(i,j); w7(i,L(j))= w7(i,L(j))+1; end endelseif (x(j)==2008) if(flag(i,j)<=2)&& ((T(i,j))>0)&&(~isnan(T(i,j))) for i=1:120 E8(i,L(j),w8(i,L(j)))= T(i,j); w8(i,L(j))= w8(i,L(j))+1; end end elseif (x(j)==2009) if(flag(i,j)<=2)&& ((T(i,j))>0)&&(~isnan(T(i,j))) for i=1:120 E9(i,L(j),w9(i,L(j)))= T(i,j); w9(i,L(j))= w9(i,L(j))+1; end end elseif (x(j)==2010) if (flag(i,j)<=2)&& ((T(i,j))>0)&&(~isnan(T(i,j))) for i=1:120 E10(i,L(j),w10(i,L(j)))= T(i,j); w10(i,L(j))= w10(i,L(j))+1; end endelseif (x(j)==2011) if(flag(i,j)<=2)&& ((T(i,j))>0)&&(~isnan(T(i,j))) for i=1:120 E11(i,L(j),w11(i,L(j)))= T(i,j); w11(i,L(j))= w11(i,L(j))+1; end endelseif (x(j)==2012) if(flag(i,j)<=2)&& ((T(i,j))>0)&&(~isnan(T(i,j))) for i=1:120 E12(i,L(j),w12(i,L(j)))= T(i,j); w12(i,L(j))= w12(i,L(j))+1; end end elseif (x(j)==2013) if(flag(i,j)<=2)&& ((T(i,j))>0)&&(~isnan(T(i,j))) for i=1:120 E13(i,L(j),w13(i,L(j)))= T(i,j); w13(i,L(j))= w13(i,L(j))+1; end end end end
I printed E4. The results I get is attached in the question.
Best Answer