2013-09-28 156 views
1

我是Matlab新手,所以如果问题很简单,我很抱歉。 我有一个fitobject,使用
fit1 = fit(x, y, 'smoothingspline')创建。计算适合的面积

现在我想计算适合度下的面积。 我该如何做到这一点?拟合似乎表现在与立场曲线不同的方式。

我试过trapz(fit1),但失败了。

回答

2

取而代之的fitobject你需要使用实际插数据,这就需要在你的代码的一些变化:

% example data 
x = (0:1:10)'; 
y = 10*x-x.^2; 

% reduced step size 
x2 = (0:0.001:10)'; 

%interpolated data by using 'spline' 
y2 = interp1(x,y,x2,'spline'); 

%calculation of data as suggested 
A = trapz(x2,y2);