|
楼主 |
发表于 2017-7-19 20:26
|
显示全部楼层
clc
clear all
t=1:1001;%a1为第一个元素,a2为最末一个元素,a3表示x共有a3个元素,
y=cos(2*pi*t/50)+0.6*cos(2*pi*t/25)+0.5*sin(2*pi*t/200);
[indmin,indmax,indzer] = extr(y);%找到y的极值
%*****************************
nbsym = 4; % 边界延拓点数
[tmin,tmax,mmin,mmax] = boundary_conditions_Jingxiang(indmin,indmax,t,y,y,nbsym);
%*然后对延拓后的极值点做三次样条插值,使其曲线光滑
envmax = interp1(tmax,mmax,t,'smoothn');
envmin = interp1(tmin,mmin,t,'smoothn');
envmoy = (envmax + envmin)/2;
%--------------------------------------------
figure(1)
plot(t,y);hold on;
plot(t,envmax,'r-.');
plot(t,envmin,'r-.');
plot(t,envmoy,'b-.');
[img]桌面[/img] |
|