필터 지우기
필터 지우기

why the plot curve is not smooth as the fitted curve

조회 수: 3 (최근 30일)
li yan
li yan 2016년 12월 28일
편집: dpb 2016년 12월 28일
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?

답변 (1개)

dpb
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.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by