MATLAB: short function taking 20+ minutes to run -


i'm using xeon quad-core processor 64gb of ram. program running function has 89 data points. it's been on 20 minutes , matlab still "busy" computing program. code below reveal reason why it's taking long compute?

function last15minsofday=last15minsofday(time,price) % last15minsofday takes average of prices between 3:45 , 4:00. timestr=cellstr(datestr(time)); timedbl=datevec(timestr); times=and(timedbl(:,4)==14,timedbl(:,5)>=45)+and(timedbl(:,4)==15,timedbl(:,5)==0); priceidx=find(times); z=find(fwdshift(1,priceidx)~=priceidx+1); z=[1; z]; mu=zeros(length(z),1); = 1:length(z);     while < length(z)         mu(i)=mean(price(priceidx(z(i):z(i+1))));     end end last15minsofday=mu; 

i no expert in matlab part looks funny:

for = 1:length(z);     while < length(z)         mu(i)=mean(price(priceidx(z(i):z(i+1))));     end end 

specifically not see i being incremented in inner loop inner loop run indefinitely.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -