why the plot curve is not smooth as the fitted curve
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I fitted a Quadratic curve, such as
f = fit(x,y, 'ploy2');
If I plot the fitting curve plot(f, x, y)
plot(f, x, y);
the curve is smooth, but if I plot the curve like this
yy = f.p1 * x.^2 + f.p2 * x + f.p3;
plot(x, yy);
the plotted curve is not as smooth as the curve plotted using the syntax plot(f, x, y). What's the difference between this two function callings?
0 Kommentare
Antworten (1)
dpb
am 28 Dez. 2016
Bearbeitet: dpb
am 28 Dez. 2016
The supplied plot function that is fit -object aware uses an internally-determined number of points to evaluate the function that are more than those in the data set itself--I just did a test here--for a sample dataset of length 15 where I fit y=x.^2+rand(size(x))*10; for a vector x=[1:15];
>> f=fit(x',y','poly2'); % fit the above quad+noise
>> h=plot(f,x,y) % use the builtin plot; return line handles
h =
633.0012
634.0002
>> tmp=get(h(1),'xdata'); % get the data for the raw data...
>> length(tmp) % and show how many points were there--
ans =
15
>> tmp=get(h(2),'xdata'); % ditto for the curve of the fit...
>> length(tmp)
ans =
1013
>>
As you can see, it computed the fit at over 1000 points internally to draw a smooth curve whereas your manual plot is just "connecting the dots" between the fitted points since you only evaluated at the input values.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!