Smoooth and Differentiate
% function ynew=smoothdiff(dados,xnew,sdx,q,nmin)
%
% This function smoothes and differentiates a sequence of numbers based on
% an algorithm similar to Savistky and Golay. 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 range of data to be used in the interpolation
% nmin - is the minimum data points to be used in the interpolation.
% q - is the degree of the polynomial to be used in the interpolation
%
% ALGORITHM:
% For each point xi of the xnew vector, this function finds the least
% squares polynomial passing through the experimental points lying between
% [xi-sdx, xi+sdx].
% Using this polynomial it calculates, with polyval, new values for the
% function 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
%
Cite As
Carlos J. Dias (2024). Smoooth and Differentiate (https://www.mathworks.com/matlabcentral/fileexchange/34772-smoooth-and-differentiate), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Mathematics > Interpolation >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.