finding absolute error of approximated function - matlab

和自甴很熟 提交于 2019-12-11 09:06:21

问题


During an experiment i registered several points. Thereafter I approximated them with 9th order polynomial. I need to find the absolute error of the measurements and the approximated function on y axis. Any idea?

*edit:

y = [0.006332 0.04056 0.11813 0.1776723 0.23840 0.29827 0.358396...   
0.418149 0.4786 0.478154 0.538114 0.53862 0.598954 0.659804...
0.720267 0.781026 0.8412 0.901548 0.962022 1.022567 1.083291...
1.143653 1.20449 1.14398 1.02273 0.962285 0.90203 0.841474...
0.780881 0.720346 0.659896 0.579599 0.539505 0.478662 0.418963...
0.35859 0.299039 0.238886 0.179108 0.118999 0.058841 0.006249...
0.06189];
x2 = linspace (1,43,43);
x2 = x2';
y = y';
f = fit(x2,y,'poly9');
figure()
plot(f,x2,y)

回答1:


This will do it:

y_fit = f(x2);
error = y - y_fit;

hold on
plot(x2, error)

% Several popular error norms:
norm(error, 1)
norm(error, 2)
norm(error, Inf)

Like y, the variable error is a vector. If you want to reduce this vector to a single number, you can use one the norms. See this for more on error norms.



来源:https://stackoverflow.com/questions/30548583/finding-absolute-error-of-approximated-function-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!