Hello,
I'm struggling with understanding the code below. I was hoping to give my best interpretation of what's going on, and hope that I'm right.
for FilesToRead = 1 : length(FileNames) y = load(fullfile(Directory, FileNames{FilesToRead})); y = {y}; n = 400000; for i=1:length(y) x{i}=(1:length(y{i}))'; end for ii=1:length(y) for k=1:length(y{ii})/n coeffs{ii}(k,:)=polyfit(x{ii}(n*(k-1)+1 : k*n),y{ii}(n*(k-1)+1 : k*n),1); yfit{ii}(k,:)=coeffs{ii}(k,2)+coeffs{ii}(k,1)*x{ii}(n*(k-1)+1 : k*n); end end for ii=1:length(y) dd{ii}= subsref(yfit{ii}.', substruct('()', {':'})).'; dd2{ii}=y{ii}(1:length(dd{ii}))-dd{ii}'; end for i=1:length(dd2) t{i}=zeros(1,length(dd2{i})); end t{1}=1:length(dd2{1}); for i=2:length(dd2) t{i}= t{i-1}(end)+[1:length(dd2{i})]; end clear coeffs dd i ii k prompt ws yfit yRaw=y; xRaw=x; x=t; y=dd2; clear dd2 t % Window for variance - 5 seconds = 100,000
n = 100000; for i=1:length(y) for k=1:length(y{i})/n a(k)=var(y{i}(n*(k-1)+1:k*n)); end v{i}=a; a=[]; end t{1}=1:length(v{1}); for i=2:length(y) t{i}=t{i-1}(end)+[1:length(v{i})]; end for i=1:length(t) tm{i} = t{i}.*((n/20000)/60); % time in minutes
endend
So essentially, every 400,000 data points, a 1st degree polynomial is fitted to the 400,000 points. Then, the data is zeroed, or flattened, where the slope of the polynomial was turned to 0, and every data point had an equal number removed from from the area on the slope the data point was located.
This is done to the entire data set. Those new values are then stored, and variance data is gathered from every 100,000 data points.
Is this the general gist?
Best Answer