2013-09-28 163 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);