寻找近似函数的绝对误差-MATLAB [英] finding absolute error of approximated function - matlab

查看:157
本文介绍了寻找近似函数的绝对误差-MATLAB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在实验过程中,我记录了几点.此后,我用9阶多项式对其进行了近似.我需要找到测量的绝对误差以及y轴上的近似函数.有什么主意吗?

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?

*

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)

推荐答案

这可以做到:

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)

y一样,变量error是向量.如果要将这个向量简化为一个数,可以使用一个范数. 有关错误规范的更多信息,请参见此.

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.

这篇关于寻找近似函数的绝对误差-MATLAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆