1.单次测量的中误差、算数平均值的中误差
array = [
120.0360
120.0390
120.0260
120.0270
120.0350
120.0360
120.0310
120.0250
119.9830
120.0410];
average = mean(array);
r = array - average;
error1 = (sum(r.^2)/(size(array,1)-1))^(1/2);%单次测量的中误差
error2 = error1/size(array,1)^(1/2);%算数平均值的中误差
disp(average);
disp(error1);
disp(error2);
120.0279
0.0167
0.0053
2.加权求最或然值
average_array = [
36
42
33];
error_array = [
0.7000
1.2000
0.7000];
average = sum(average_array.*error_array)/sum(error_array);%加权求最或然值
disp(average);
37.9615
我错了……权值是精度的平方的导数……代码差不多,懒得改了
3.误差传递函数

syms x y real;
f(x,y) = (x^2 + y^2)^(1/2);
df_array = [
diff(f,x)
diff(f,y)];
delta_array = [
0.0050
0.0070];
x = 5.02;
y = 8.98;
R = eval(f);
error = sum((eval(df_array).*delta_array).^2).^(1/2);%误差传播定律
disp(R);
disp(error);
10.2879
0.0066
4.函数拟合
来源:https://www.cnblogs.com/yabin/p/6417566.html

历史出错代码1
% 自变量和应变量
x = [
14.5200
15.2500
15.6000
16.4700
16.9200];
Y = [
116.2000
162.3000
176.1000
251.8000
290.2000];
% 被拟合的函数 用于 fit 函数
linearFun1 = 'a*x+b';
powerFun1 = 'a*x^b+c';
indexFun1 = 'a*exp(b*x)+c';
sinFun1 = 'a*sin(x+b)+c';
Fun1_array = {
linearFun1
powerFun1
indexFun1
sinFun1};
% 被拟合的函数的自变量 用于 fit 函数
linearX1 = {
'x'};
powerX1 = {
'x'};
indexX1 = {
'x'};
sinX1 = {
'x'};
X1_array = {
linearX1
powerX1
indexX1
sinX1};
% 被拟合的函数的系数 用于 fit 函数
linearCo1 = {
'a','b'};
powerCo1 = {
'a','b','c'};
indexCo1 = {
'a','b','c'};
sinCo1 = {
'a','b','c'};
Co1_array = {
linearCo1
powerCo1
indexCo1
sinCo1};
% 被拟合的函数 用于 nlinfit 函数
linearFun2 = @(x,Co2) Co2(1).*x+Co2(2);
powerFun2 = @(x,Co2) Co2(1).*x.^Co2(2)+Co2(3);
indexFun2 = @(x,Co2) Co2(1).*exp(Co2(2).*x)+Co2(3);
sinFun2

本文介绍了在Matlab中进行单次测量的中误差、算数平均值的中误差计算,以及加权求最或然值的方法。在函数拟合过程中,作者遇到了错误,通过调试解决了模型函数定义、参数传递和矩阵运算等问题。最后,文中还提到了莫迪图和误差线图的绘制,虽然在绘制过程中遇到一些问题,但最终得到了正常运行的代码。
最低0.47元/天 解锁文章
2464

被折叠的 条评论
为什么被折叠?



