% fitting world population data to exponential model clear all % data 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); % matrix and vector to define min squares problem A=[tim ones(size(tim))]; B=log(popul); % our estimated parameters PAR=A\B % now let us see how our estimates compare to data for kk=1:length(B) ppl(kk)=PAR(1)*tim(kk)+PAR(2); end % comparing logarithms plot(tim,ppl,tim,log(popul),'or') pause % or % comparing values plot(tim,exp(ppl),tim,popul,'or')