ADAPTIVE DEGREE SMOOTHING AND DIFFERENTIATION
% function ynew=adsmoothdiff(dados,xnew,sdx,isdx,q,nmin)
% written by Carlos J Dias
%
% ADAPTIVE DEGREE SAVISTZKY-GOLAY SMOOTHING AND DIFFERENTIATION
% This function smooths and differentiates a sequence of numbers based on
% an algorithm drawn on the ideas of Savistky and Golay and Barak.
% There are no restrictions however, on the number of points
% or on their spacing.
% This function also calculates the first derivative at the xnew points
%
% INPUT:
% dados - data in a two column matrix (first column x; second column y)
% xnew - is a vector where new ordinates are to be computed
%
% sdx - is the abscissa range of data to be used to find the least squares
% polynomial
% isdx - is a fraction of the sdx range between [0 1] where new y_values
% for xnew will be calculated. It usually is 0.8 (i.e. 80%) of the sdx range.
% q - is the highest degree of the polynomial to be used in the interpolation
% nmin - is the minimum data points to be used in the interpolation.
%
% ALGORITHM:
% For each point xnew_i of the xnew vector, this function finds the least
% squares polynomial (with polyfit) passing through the experimental points
% lying between [xnew_i - sdx, xnew_i + sdx].
% The degree of the polynomial is chosen based on a F-statistic.
% Using this polynomial it calculates, with polyval, the values for
% y and its derivative in that same interpolating window.
%
% All calculated values for each abscissa are used to compute an average
% value of the smoothed function and its derivative.
% When sdx range includes fewer points than nmin, the range is enlarged to
% include at least nmin points. This may occur more often at the edges
% of the data.
% Note that we should have nmin>q
%
% OUTPUT (ynew - 5 column matrix)
% column 1- new abscissas
% column 2- new ordinates
% column 3- their standard error
% column 4- first derivative
% column 5- no. of values that were calculated for the ith point
%
% DEMO SCRIPT (SMOOTHING OF 1000 POINTS)
% x=linspace(-10,10,1000)';
% y=1./(1+((x-2)/0.5).^2)+2./(1+((x+2)/0.5).^2);%two lorenztians
% noise=0.5*(rand(length(y),1)-0.5);
% y=y+noise;
% ynew=adsmoothdiff([x y],x,1.1,0.8,11,15);
% %(it takes about 30 s to run this script in my computer)
%
% P Barak, Analytical Chemistry 1995, 67 2758-2762
% A Savitzky, MJE Golay, Analytical Chemistry 1964, 36(8) 1627-1638
% I also acknowledge Jianwen Luo for drawing my attention to adaptive
% strategies.
Zitieren als
Carlos J. Dias (2024). ADAPTIVE DEGREE SMOOTHING AND DIFFERENTIATION (https://www.mathworks.com/matlabcentral/fileexchange/34892-adaptive-degree-smoothing-and-differentiation), MATLAB Central File Exchange. Abgerufen.
Kompatibilität der MATLAB-Version
Plattform-Kompatibilität
Windows macOS LinuxKategorien
- Signal Processing > Signal Processing Toolbox > Signal Generation and Preprocessing > Smoothing and Denoising >
Tags
Quellenangaben
Inspiriert: Modified planar rotator (MPR) method
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Live Editor erkunden
Erstellen Sie Skripte mit Code, Ausgabe und formatiertem Text in einem einzigen ausführbaren Dokument.
Version | Veröffentlicht | Versionshinweise | |
---|---|---|---|
1.1.0.0 | improvement on the title, figure and description |
||
1.0.0.0 |