Data needs to be run for every minute, figured out how to run it for one minute...But not sure how to write a FOR loop for it.

1 view (last 30 days)
I have a very large matrix of data, which I am analyzing minute by minute. For each minute's worth of data, I'm separating it by diameter intervals, to take weighted average velocities. At the end, I need to have two values for each minute's worth of data. I've pasted the chunk of code that I need to somehow integrate in to a for loop. I have 1771 minutes worth of data. In what I have pasted here, I was analyzing minute 200.
[row3,col3]=find(Min_dia(:,200)>0.25 & Min_dia(:,200)<0.375);
avgvel3=((sum((Min_vel(row3,200).*Min_count(row3,200))))./sum(Min_count(row3,200)));
[row4,col4]=find(0.375<Min_dia(:,200) & Min_dia(:,200)<0.5);
avgvel4=((sum((Min_vel(row4,200).*Min_count(row4,200))))./sum(Min_count(row4,200)));
[row5,col5]=find(0.5<Min_dia(:,200) & Min_dia(:,200)<0.625);
avgvel5=((sum((Min_vel(row5,200).*Min_count(row5,200))))./sum(Min_count(row5,200)));
[row6,col6]=find(0.625<Min_dia(:,200) & Min_dia(:,200)<0.75);
avgvel6=((sum((Min_vel(row6,200).*Min_count(row6,200))))./sum(Min_count(row6,200)));
[row7,col7]=find(0.75<Min_dia(:,200) & Min_dia(:,200)<0.875);
avgvel7=((sum((Min_vel(row7,200).*Min_count(row7,200))))./sum(Min_count(row7,200)));
[row8,col8]=find(.875<Min_dia(:,200) & Min_dia(:,200)<1);
avgvel8=((sum((Min_vel(row8,200).*Min_count(row8,200))))./sum(Min_count(row8,200)));
[row9,col9]=find(1<Min_dia(:,200) & Min_dia(:,200)<1.125);
avgvel9=((sum((Min_vel(row9,200).*Min_count(row9,200))))./sum(Min_count(row9,200)));
[row10,col10]=find(1.125<Min_dia(:,200) & Min_dia(:,200)<1.25);
avgvel10=((sum((Min_vel(row10,200).*Min_count(row10,200))))./sum(Min_count(row10,200)));
[row11,col11]=find(1.25<Min_dia(:,200) & Min_dia(:,200)<1.5);
avgvel11=((sum((Min_vel(row11,200).*Min_count(row11,200))))./sum(Min_count(row11,200)));
[row12,col12]=find(1.5<Min_dia(:,200) & Min_dia(:,200)<1.75);
avgvel12=((sum((Min_vel(row12,200).*Min_count(row12,200))))./sum(Min_count(row12,200)));
[row13,col13]=find(1.75<Min_dia(:,200) & Min_dia(:,200)<2);
avgvel13=((sum((Min_vel(row13,200).*Min_count(row13,200))))./sum(Min_count(row13,200)));
[row14,col14]=find(2<Min_dia(:,200) & Min_dia(:,200)<2.25);
avgvel14=((sum((Min_vel(row14,200).*Min_count(row14,200))))./sum(Min_count(row14,200)));
[row15,col15]=find(2.25<Min_dia(:,200) & Min_dia(:,200)<2.5);
avgvel15=((sum((Min_vel(row15,200).*Min_count(row15,200))))./sum(Min_count(row15,200)));
[row16,col16]=find(2.5<Min_dia(:,200) & Min_dia(:,200)<3);
avgvel16=((sum((Min_vel(row16,200).*Min_count(row16,200))))./sum(Min_count(row16,200)));
[row17,col17]=find(3<Min_dia(:,200) & Min_dia(:,200)<3.5);
avgvel17=((sum((Min_vel(row17,200).*Min_count(row17,200))))./sum(Min_count(row17,200)));
[row18,col18]=find(3.5<Min_dia(:,200) & Min_dia(:,200)<4);
avgvel18=((sum((Min_vel(row18,200).*Min_count(row18,200))))./sum(Min_count(row18,200)));
[row19,col19]=find(4<Min_dia(:,200) & Min_dia(:,200)<4.5);
avgvel19=((sum((Min_vel(row19,200).*Min_count(row19,200))))./sum(Min_count(row19,200)));
[row20,col20]=find(4.5<Min_dia(:,200) & Min_dia(:,200)<5);
avgvel20=((sum((Min_vel(row20,200).*Min_count(row20,200))))./sum(Min_count(row20,200)));
[row21,col21]=find(5<Min_dia(:,200) & Min_dia(:,200)<6);
avgvel21=((sum((Min_vel(row21,200).*Min_count(row21,200))))./sum(Min_count(row21,200)));
V=[avgvel3;avgvel4;avgvel5;avgvel6;avgvel7;avgvel8;avgvel9;avgvel10;avgvel11;avgvel12;avgvel13;avgvel14;avgvel15;avgvel16;avgvel17;avgvel18;avgvel19;avgvel20;avgvel21];
%DSD for each one minute average
DSD3=(sum(Min_count(row3,200)))/(Area*avgvel3*delta_T*deltaD(3,:));
DSD4=(sum(Min_count(row4,200)))/(Area*avgvel4*delta_T*deltaD(4,:));
DSD5=(sum(Min_count(row5,200)))/(Area*avgvel5*delta_T*deltaD(5,:));
DSD6=(sum(Min_count(row6,200)))/(Area*avgvel6*delta_T*deltaD(6,:));
DSD7=(sum(Min_count(row7,200)))/(Area*avgvel7*delta_T*deltaD(7,:));
DSD8=(sum(Min_count(row8,200)))/(Area*avgvel8*delta_T*deltaD(8,:));
DSD9=(sum(Min_count(row9,200)))/(Area*avgvel9*delta_T*deltaD(9,:));
DSD10=(sum(Min_count(row10,200)))/(Area*avgvel10*delta_T*deltaD(10,:));
DSD11=(sum(Min_count(row11,200)))/(Area*avgvel11*delta_T*deltaD(11,:));
DSD12=(sum(Min_count(row12,200)))/(Area*avgvel12*delta_T*deltaD(12,:));
DSD13=(sum(Min_count(row13,200)))/(Area*avgvel13*delta_T*deltaD(13,:));
DSD14=(sum(Min_count(row14,200)))/(Area*avgvel14*delta_T*deltaD(14,:));
DSD15=(sum(Min_count(row15,200)))/(Area*avgvel15*delta_T*deltaD(15,:));
DSD16=(sum(Min_count(row16,200)))/(Area*avgvel16*delta_T*deltaD(16,:));
DSD17=(sum(Min_count(row17,200)))/(Area*avgvel17*delta_T*deltaD(17,:));
DSD18=(sum(Min_count(row18,200)))/(Area*avgvel18*delta_T*deltaD(18,:));
DSD19=(sum(Min_count(row19,200)))/(Area*avgvel19*delta_T*deltaD(19,:));
DSD20=(sum(Min_count(row20,200)))/(Area*avgvel20*delta_T*deltaD(20,:));
DSD21=(sum(Min_count(row21,200)))/(Area*avgvel21*delta_T*deltaD(21,:));
DSD=[DSD3;DSD4;DSD5;DSD6;DSD7;DSD8;DSD9;DSD10;DSD11;DSD12;DSD13;DSD14;DSD15;DSD16;DSD17;DSD18;DSD19;DSD20;DSD21];
%Reflectivity for each one minute average
Z=sum(DSD.*(dia_class(3:21)'.^6).*deltaD(3:21));
dBZ=10*log(Z);
%Rainfall intensity for each one minute average
R=((6*pi)/(10^4))*sum(DSD.*(dia_class(3:21)'.^3).*V.*deltaD(3:21));

Answers (1)

Sean de Wolski
Sean de Wolski on 8 Feb 2013

Tags

Community Treasure Hunt

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

Start Hunting!