How can I control the output from the SMOOTH command in the Curve Fitting Toolbox?

1 view (last 30 days)
How can I control the output from the SMOOTH command in the Curve Fitting Toolbox?
Is it possible to control the number of output data points generated from the SMOOTH command in the Curve Fitting Toolbox?
If I have 50 input points, is it possible to use the SMOOTH command from the Curve Fitting Toolbox and not get 50 output points?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Currently, there is no direct way of using the function SMOOTH to control the number of smoothed output points. The SMOOTH command generates one point for each input data point, thus smoothing the data.
The output of the data is the same dimension as the data. In other words, if you want to smooth a vector of size 50, it will generate an output vector of size 50.
An enhancement request for the functionality to control the number of output points using the SMOOTH command has been forwarded to our development staff to be reviewed for a future release.
As workaround you can use the SMOOTH function to smooth the data and then use the EXCLUDEDATA function in order to reduce the number of data points of the smooth output. The function EXCLUDEDATA marks some data to be excluded. The following example demonstrates this:
load count.dat
y = count(:,1);
yy = smooth(y,'loess');
t = 1:length(y);
plot(t,y,'r-.',t,yy,'b-')
legend('Original Data','Smoothed Data Using ''loess''',2)
ind = find((yy>5)&(yy<20));
outliers = excludedata(t',yy,'indices',ind);
tnew=t(outliers);
yynew=yy(outliers);
figure
plot(tnew,yynew,'b-')
legend('Reduced data and Smoothed Data Using ''loess''',2)

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!