MATLAB CURVE FITTING TOOLBOX - RELEASE NOTES User's Guide Page 207

  • Download
  • Add to my manuals
  • Print
  • Page
    / 216
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 206
smooth
4-131
The first four elements of yy are given by
yy(1) = y(1)
yy(2) = (y(1)+y(2)+y(3))/3
yy(3) = (y(1)+y(2)+y(3)+y(4)+y(5))/5
yy(4) = (y(2)+y(3)+y(4)+y(5)+y(6))/5
Because of the way that the end points are treated, the result shown above
differs from the result returned by the
filter function described in Difference
Equations and Filtering in the MATLAB documentation.
In this example, generate random data between 0 and 15, create a sine wave
with noise, and add two outliers with the value 3.
rand('state',2);
x = 15*rand(150,1);
y = sin(x) + (rand(size(x))-0.5)*0.5;
y(ceil(length(x)*rand(2,1))) = 3;
Smooth the data using the loess and rloess methods with the span specified
as 10% of the data.
yy1 = smooth(x,y,0.1,'loess');
yy2 = smooth(x,y,0.1,'rloess');
Plot original data and the smoothed data.
[xx,ind] = sort(x);
subplot(2,1,1)
plot(xx,y(ind),'r.',xx,yy1(ind),'k-')
set(gca,'YLim',[-1.5 3.5])
legend('Original Data','Smoothed Data Using ''loess''',2)
subplot(2,1,2)
plot(xx,y(ind),'r.',xx,yy2(ind),'k-')
set(gca,'YLim',[-1.5 3.5])
legend('Original Data','Smoothed Data Using ''rloess''',2)
Page view 206
1 2 ... 202 203 204 205 206 207 208 209 210 211 212 ... 215 216

Comments to this Manuals

No comments