Polynomial curve fitting
古いコメントを表示
Hi,
I am trying to make polynomial curve fitting in sine wave. First I have created the wave and I took 10 samples, on which I add noise from a gaussian distribution.Now, I am trying to make curve fitting with a polynomial of 9th degree.I think that my results are wrong as the green curve is linear between the points.Does anybody know if am I correct?If there is a mistake I would like to inform me.
Thanks in advance
%%%%%%% code %%%%%%%%% t=0:0.001:1; k=sin(2*pi*t); plot(t,k); x=linspace(0,1,10);
for i=1:1:10 y(i)=sin(2*pi*x(i)); end;
r = randn(10,1);
for i=1:1:10 y_noise(i)=y(i)+r(i); end;
p = polyfit(x,y,9);
x2 = x; y2 = polyval(p,x2); plot(x,y,'o',x2,y2,t,k) grid on
disp(p)
RMSE=sqrt(mean((y-y2).^2+(x-x2).^2));
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Linear and Nonlinear Regression についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!