% fitting world population data to exponential model % this time we are minimizing sum of squares of the % population sizes % we use the Matlab function fmins clear all popdt=[-10000 1; -8000 5; -6500 5; -5000 5; -4000 7; -3000 14; -2000 27; -1000 50; -500 100; -400 162; -200 150; 1 170; 200 190; 400 190; 500 190; 600 200; 700 207; 800 220; 900 226; 1000 254; 1100 301; 1200 360; 1250 400; 1300 360; 1340 443; 1400 350; 1500 425; 1600 545; 1650 470; 1700 600; 1750 629; 1800 813; 1850 1128; 1900 1550; 1910 1750; 1920 1860; 1930 2070; 1940 2300; 1950 2400]; tim=popdt(:,1); popul=popdt(:,2); % find quadratic fit parameters % [0.0006 5] is our initial guess of % parameters which follows from least squares % for logarithms % QPAR - is the vestor of parameters % QPAR(1) - r % QPAR(2) - log(N_0) QPAR=fmins('wp_fun',[0.0006 5]) % now let us see how our estimates compare to data for kk=1:length(tim) qppl(kk)=exp(QPAR(1)*tim(kk)+QPAR(2)); end plot(tim,log(qppl),tim,log(popul),'or') pause % or plot(tim,qppl,tim,popul,'or')