郭沫若最著名的一句话(包括名言)

2023-05-27 16:42   geyange.com

<a href=http://www.geyange.com/mingyan/1377.html target=_blank class=infotextkey>郭沫若</a>最著名的一句话(包括名言)

求解的Matlab程序代码:  

编写M文件如下:

Malthus模型:

首先对数据进行拟合:

>> year=1988:1:2001;

>>population=[11.1026,11.2074,11.4333,11.5823,11.7171,11.8517,11.9850 12.1121,12.2389,12.3626,12.4761,12.5786,12.6743,12.7627];

>> cftool

图一  拟合数据图

Matlab自动生成的拟合代码:

function [fitresult, gof] = createFit2(year, population)

%CREATEFIT2(YEAR,POPULATION)

%  Create a fit.

%

%  Data for 'untitled fit 1' fit:

%      X Input : year

%      Y Output: population

%  Output:

%      fitresult : a fit object representing the fit.

%      gof : structure with goodness-of fit info.

%

%  另请参阅 FIT, CFIT, SFIT.

%  由 MATLAB 于 06-Apr-2022 01:20:13 自动生成

%% Fit: 'untitled fit 1'.

[xData, yData] = prepareCurveData( year, population );

% Set up fittype and options.

ft = fittype( 'xm/(1+(xm/11.1026-1)*exp(-r*(t-1988)))', 'independent''dependent'

opts = fitoptions( 'Method', 'NonlinearLeastSquares' );

opts.Display = 'Off';

opts.StartPoint = [0.2 500];

% Fit model to data.

[fitresult, gof] = fit( xData, yData, ft, opts );

% Plot fit with data.

figure( 'Name', 'untitled fit 1' );

h = plot( fitresult, xData, yData );

legend( h, 'population vs. year', 'untitled fit 1', 'Location', 'NorthEast' );

% Label axes

xlabel year

ylabel population

grid on

将以上代码保存当前文件夹,并在新的文件夹中调用这个函数得到参数的拟合值和预测的效果。

计算结与结论:  

通过Matlab进行计算,得到如下答案:

>> year=1988:1:2001;

>>population=[11.1026,11.2074,11.4333,11.5823,11.7171,11.8517,11.9850 12.1121,12.2389,12.3626,12.4761,12.5786,12.6743,12.7627];

cftool

>>[fitresult, gof] = createFit1(year, population)

>>t = 2002:2004;

>>xm = 14.42;   

>>r =  0.06451;

>>predictions = xm./(1+(xm./11.1026-1).*exp(-r.*(t-1988)));

>>figure(2)

>>plot(year,population,'o',t,predictions,'.')  

>>disp(predictions)  

fitresult =

General model:

fitresult(t) = xm/(1+(xm/11.1026-1)*exp(-r*(t-1988)))

Coefficients (with 95% confidence bounds):

r =     0.06451  (0.05625, 0.07277)

xm =       14.42  (14.03, 14.82)


文章版权声明:除非注明,否则均为格言阁原创文章,转载或复制请以超链接形式并注明出处。
取消