matlab - How to make a vector that follows a certain trend? -
matlab - How to make a vector that follows a certain trend? -
i have set of info on 4000 points. want exclude grooves them, ideally point start. info illustration this:
the problem noise @ top of plateaus. have idea, in take average value of mutual within boundaries (again, ideally sth reddish line here:
and build temporary matrix, fill 1 1 y if less average. if y(i) rising above average, matrix find minima , compare global minima. if temporary matrix's minima wouldn't sth 80% of global minima, discarded noise.
i've tried using mean(y), interpolating , fitting in polynomial (the greenish line) - none of method cutting point satisfied.
i need extremely robust , doesn't need quick. top , bottom values can vary lot, shape of plateaus. groove width more or less same.
do have ideas? again, point extract values create groove.
how median filter?
let's define noisy info similar yours, , plot in blue:
x = .2*sin((0:9999)/1000); %// signal x(1000:1099) = x(1000:1099) + sin((0:99)/50*pi); %// noise: spike x(5000:5199) = x(5000:5199) - sin((0:199)/100*pi); %// noise: wider spike x = x + .05*sin((0:9999)/10); %// noise: high-freq ripple plot(x)
now apply median filter (using medfilt2
image processing toolbox) , plot in red. parameter k
controls filter memory. should chosen big compared noise variations, , little compared signal variations:
k = 500; %// filter memory. take needed y = medfilt2(x,[1 k]); hold on plot(y, 'r', 'linewidth', 2)
matlab signals signal-processing
Comments
Post a Comment