matlab 曲面拟合(matlab曲面拟合)
一、matlab;拟合曲面;曲面交线函数;
第一:plot有很多参数啊用来改色彩样式的。
为了便于区分你可以一个画成网格另一个画成实心曲面。或者两个画成不同颜色的网格。
你查查 help plot你可以得到你要的
第二个问题,我不知道你想得到什么结论。
第三个是拟合结果和统计信息,很多拟合是得不到具体函数的。
你的这个就是个例子,它没有计算出明确表达式只生成了一个f(x y):
f(x,y)=分段线性曲面,根据x y得到系数p值。
这两条说的是定义域:在x值(主值 0方差 2.223)和y值(主值-0.6667和方差 2.567)
系数:
p=系数结构。
吻合度:
这些都是统计信息:
误差项平方和 SSE: 1.972e-31
R方(吻合系数):R-square: 1
校正R方:Adjusted R-square: NaN
均方根误差 RMSE: NaN
给你一些资料:
SSE(趋向0最好)-- The sum of squares due to error. This statistic measures the deviation of the responses from the fitted values of the responses. A value closer to 0 indicates a better fit.
R-square(趋向1最好)-- The coefficient of multiple determination. This statistic measures how successful the fit is in explaining the variation of the data. A value closer to 1 indicates a better fit.
Adjusted R-square(趋向1最好)-- The degree of freedom adjusted R-square. A value closer to 1 indicates a better fit. It is generally the best indicator of the fit quality when you add additional coefficients to your model.
RMSE(趋向0最好)-- The root mean squared error. A value closer to 0 indicates a better fit.
二、matlab 散点拟合三维曲面写出曲面表达式
我现在也是这个情况啊!正是相当纠结呢!在网上看到了这个···
因为这个函数的形式比较特殊,对其两边取对数后得到
log(y)=log(a)+b*log(x1)+c*log(x2)
于是立即就转换为了线性拟合
[1 log(x1) log(x2)]*[log(a) b c]'=log(y)
于是[log(a) b c]'=[1 log(x1) log(x2)]\log(y)
这样就可以得到a,b,c了。不需要进行非线性拟合。
下面是程序:(对于x1、x2、y的赋值部分这里就不写了,你自己在前面加上即可)
p=[ones(length(y),1) log([x1 x2])]\log(y);%就这一句话就搞定了
a=exp(p(1)),b=p(2),c=p(3)%这就是拟合后的参数值
y%这是采样点y的值
a*x1.^b.*x2.^c%这是拟合后在采样点得到的值,可以和y比较一下,很接近
三、matlab如何进行曲面拟合我有几十组(x,y,z
曲面拟合可以按下列步骤进行:
1、根据x,y,z数据,可以用cftool拟合工具箱的常用函数去拟合,判断(x,y,z)大概符合那个曲面方程。(注:cftool拟合工具箱有时候不一定与实际相符)
2、建立曲面方程模型函数,如func=@(a,x) a(1)*x(1)^2+a(2)*x(2)^2,这里x(1)→x,x(2)→y
3、用 nlinfit()或lsqcurvefit()拟合函数,去拟合模型函数的系数a。
a= nlinfit(x,z,func,a0)
a=lsqcurvefit(func,a0,x,z)
4、计算 z数据值与z拟合值的拟合度,即决定系数R²是否接近于1。愈接近于1其拟合精度也就愈高。