[Scilab-users] Envelop of a noisy curve

Rafael Guerra jrafaelbguerra at hotmail.com
Mon Apr 27 13:15:43 CEST 2015


Hello,Samuel’s ingenious method may need to be complemented with band pass
filtering pre-processing.In the modified example below, the signal is the
low frequency component and the noise the high frequency (need to run script
twice answering N and Y).Other situations may arise in practice and
computing the envelope does not seem trivial.// Code adapted from Samuel
Gougeon’s// Run this script first with no filter (input=N) and then with
filter (=Y) clear;Ns= 1001;x = linspace(0,10,Ns);y =
exp((-x)/5).*sin(2*x.*x);y = y + 0.1*max(y)*rand(x)// Simple low-pass
filter, to be improved with better implementationfc=1e-3; n=5; //Low-cut fc,
order=2*n (adapt parms to given
signal&noise)[h,hm,fr]=wfir("lp",2*n,fc,"hm",[])y0=convol(h,y);y0=y0(n+1:Ns+n);y0=y0*max(y)/max(y0); 
// normalize filter outputclf;plot2d(x,y)e = gce(); e =
e.children;e.foreground =
color("grey");plot(x,y0,'black')str=input("Envelope from filtered signal
Y/[N]?",'string')if str=='y'| str=='Y' then y=y0; endd = diff(y) ./
diff(x);pmax = find(d(1:$-1)>=0 & d(2:$)<0)+1;pmin = find(d(1:$-1)<0 &
d(2:$)>0)+1;// edges correctionsif d(1)<0 then pmax = [1 pmax]; endif d($)<0
then pmin = [pmin length(y)];
endplot(x(pmax),y(pmax),"r",x(pmin),y(pmin),"b")Regards,Rafael



--
View this message in context: http://mailinglists.scilab.org/Scilab-users-Envelop-of-a-noisy-curve-tp4032140p4032163.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20150427/d400265e/attachment.htm>


More information about the users mailing list