Dynamic moving average with specific criteria
Mostrar comentarios más antiguos
I have some code that takes a column vector and performs a moving average on these data. The results from the moving average are placed in a cell array. Then, the window size of the averaging function increases (window size is set by i=1:60; amd n=round(10.^(i/10)); ) and the moving average is repeated. The results are then placed in to the next column of the cell array...and the process repeated:
m=cell(1000001:60);
sd=zeros(1,60);
for i=1:60;
n=round(10.^(i/10));
mask=ones(n,1)/n;
a=conv(P,mask,'valid');
m{i}=a;
sd(i)=std(a);
end
The problem:
In the original data being analysed (i.e. P), all values are either positive or 0. My goal is to only perform the averaging function on windowed data that do not either begin or end with a zero. It's ok for the block of data to contain zeroes, its just I don't want the averaging function to return a value to the cell array if the block begins or ends with a 0. I'm pretty new to matlab, and can't see how I can tell the code this, so any suggestions would be greatly appreciated.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!