why the plot curve is not smooth as the fitted curve
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
dpb
2016 年 12 月 28 日
編集済み: dpb
2016 年 12 月 28 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with Curve Fitting Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!