copyendpoints.m

来自「一种新的时频分析方法的matlab源程序。」· M 代码 · 共 88 行

M
88
字号
function [begx, begy, endx, endy] = copyendpoints(x, y, datay, type)

% The function COPYENDPOINTS returns extrema endpoints and their coordinates.
% It copies endpoints of extrema and makes sure that 
% spline encompasses dataset, and extrema are outside of the bounds 
% of the original data, to prevent errors in creating the envelope.
%
% Calling sequence-
% [begx, begy, endx, endy] = copyendpoints(x, y, datay, type)
%
% Input-
%	x	    -the x coordinates of the extrema
%	y	    -the y values of the extrema
%	datay	-the original dataset from which the extrema values
%		    come from
%	type	-equals -1 if extrema are minimum extrema,
%		    equals  1 if they are maximum extrema
% Output-
%	begx	-the x values for the beginning extrema endpoints
%	begy	-the y values for the beginning extrema endpoints
%	endx	-the x values for the end extrema endpoints
%	endy	-the y values for the end extrema endpoints
%
% Used by-
%    NFAM5M

% Karin Blank (NASA GSFC)	May 5, 2003 Initial
%----- Initialize the distance
if(length(x) > 1)
    delta_x = x(2) - x(1);
else
    delta_x = x(1);
end
    
%----- Make sure distances are greater than the distance to data end
if((x(1) - delta_x) > 0)
    delta_x = x(1);
end

y_can = y(1);

if(type == 1)
    %----- Make sure extrema is greater than original data
    if((y_can < datay(1)))
        y_can = datay(1);
    end
else
    if((y_can > datay(1)))
        y_can = datay(1);
    end
end

if(length(x) > 1)
    delta_x2 = x(end) - x(end-1);
else
    delta_x2 = length(datay)-x(end);
end
    
if((delta_x2 + x(end)) < length(datay))
    delta_x2 = length(datay) - x(end);
end

y_can2 = y(end);

if(type==1)
    if(y_can2 < datay(end))
        y_can2 = datay(end);
    end
else
    if(y_can2 > datay(end))
        y_can2 = datay(end);
    end
end

begx = x(1)-delta_x;
begy = y_can;
endx = x(end)+delta_x2;
endy = y_can2;

for i=1:4
    begx = [begx(1)-delta_x, begx ];
    begy = [y_can, begy];
    
    endx = [endx, endx(end)+delta_x2];
    endy = [endy, y_can2];
end

return;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?