I made a Xcos simulation model and I got a swinging output curve as below chart 1.
Now I want to draw an envelope curve of the swinging curve as below chart 2 red line.
How can I draw the envelope curve by Xcos or Scilab console or Scinotes ?
Hello,
The following example explains how to compute the local minima and maxima then plot two splines passing through these points:
t=linspace(0,50,1000);
clf
y = exp(-((t-25)/10).^2).*(cos(2*t));
ksup=1+find((y(2:$-1)>=y(1:$-2)) & (y(2:$-1)>=y(3:$)))
kinf=1+find((y(2:$-1)<=y(1:$-2)) & (y(2:$-1)<=y(3:$)))
plot(t,y)
plot(t,interp(t,t(ksup),y(ksup),splin(t(ksup),y(ksup))),'r')
plot(t,interp(t,t(kinf),y(kinf),splin(t(kinf),y(kinf))),'r')