이 번역 페이지는 최신 내용을 담고 있지 않습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.
사용자 지정 비선형 인구 조사 데이터 피팅
이 예제에서는 범위, 계수 및 문제 종속적 파라미터를 지정하여 인구 조사 데이터에 사용자 지정 수식을 피팅하는 방법을 보여줍니다.
census.mat의 데이터를 불러와서 플로팅합니다.
load census plot(cdate,pop,'o') hold on
사용자 지정 비선형 모델 y = a(x-b)n에 대한 fit options 구조체와 fittype 객체를 만듭니다. 여기서 a와 b는 계수이고 n은 문제 종속적 파라미터입니다. 문제 종속적 파라미터에 대한 자세한 내용은 fittype 함수 페이지를 참조하십시오.
s = fitoptions('Method','NonlinearLeastSquares',... 'Lower',[0,0],... 'Upper',[Inf,max(cdate)],... 'Startpoint',[1 1]); f = fittype('a*(x-b)^n','problem','n','options',s);
피팅 옵션과 값 n = 2를 사용하여 데이터를 피팅합니다.
[c2,gof2] = fit(cdate,pop,f,'problem',2)
c2 = General model: c2(x) = a*(x-b)^n Coefficients (with 95% confidence bounds): a = 0.006092 (0.005743, 0.006441) b = 1789 (1784, 1793) Problem parameters: n = 2
gof2 = struct with fields:
sse: 246.1543
rsquare: 0.9980
dfe: 19
adjrsquare: 0.9979
rmse: 3.5994
피팅 옵션과 값 n = 3을 사용하여 데이터를 피팅합니다.
[c3,gof3] = fit(cdate,pop,f,'problem',3)
c3 = General model: c3(x) = a*(x-b)^n Coefficients (with 95% confidence bounds): a = 1.359e-05 (1.245e-05, 1.474e-05) b = 1725 (1718, 1731) Problem parameters: n = 3
gof3 = struct with fields:
sse: 232.0058
rsquare: 0.9981
dfe: 19
adjrsquare: 0.9980
rmse: 3.4944
피팅 결과와 데이터를 플로팅합니다.
plot(c2,'m') plot(c3,'c') legend('data','fit with n=2','fit with n=3')