math - Matlab positioning windows at a 50% overlap -


i using following code windowing data , finding mean of each window. used starting each new window directly @ end of previous window. how code modified each new window starts @ 50% overlap prior window.

 fq = 51.2; //sample rate of accelerometer   windowlength = 5; //length each window in seconds  startpos = 1; //starting position 1st win   endpos = startpos + (windowlength * floor(fq)); //end position 1st win  totalwindows = floor(length(walk)/fq/windowlength);   stats = zeros(windowlength,9);   = 1:totalwindows      epmean = mean(walk(startpos:endpos,:)); //calculate window mean       //x, y & z axis values each stat      walkfeature(i,1:4) = epmean;        //next window position      startpos = endpos+1;      endpos = startpos + (windowlength * floor(fq))  end 

not optimized that's close original code , allow specify desired overlap :

windowlengthinpoint = windowlength * floor(fq) ; %// store value  overlap = 0.2 ;  %// in portion of windowlength - 20% in example increment = floor(windowlengthinpoint*overlap) ;  startpos = 1 ; endpos = startpos + windowlengthinpoint ; lvec = length(walk) ; while endpos <= lvec     epmean = mean(walk(startpos:endpos,:)); %//calculate window mean       %// other code      %// ...      startpos = startpos + increment ;     endpos = startpos + windowlengthinpoint ; end 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -