repeated_median_trend.m
来自「三谱混合相位子波估计!! 这是我的一篇文章所涉及到的matlab 源代码」· M 代码 · 共 35 行
M
35 行
function trend=repeated_median_trend(vector,x)
% Compute the trend by means repeated median of the gradients of the vector samples
% Ref: Siegel, A.F. (1982), "Robust Regression using Repeated Medians."
% Biometrika. 69, pp 242-244
% Written by: E. R.: March 22, 2005
% Last updated:
%
% med=repeated_median_trend(vector,x)
% INPUT
% vector vector whose trend is to be calculated
% x coordinates in case the values are not equally spaced
% Default: 1:length(vector)
% OUTPUT
% trend trend
n=length(vector);
grads=zeros(n-1,1);
if nargin == 2
vector=vector(:);
x=x(:);
for ii=1:n-1
grads(ii)=median((vector(ii+1:end)-vector(ii))./(x(ii+1:end)-x(ii)));
end
else
vector=vector(:)';
for ii=1:n-1
grads(ii)=median((vector(ii+1:end)-vector(ii))./(1:n-ii));
end
end
trend=median(grads);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?