Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Popluation Growth

  1. Nov 9, 2009 #1
    muhaag.jpg

    I have this
    Code (Text):
    delete s275x05.txt; diary s275x05.txt
    clear; clc; close all; echo on
    %
    % Stewart 275/05
    %
    year=[0:1]; % n+1 = year + 50
    pop=[728 906];
    p=polyfit(year,log(pop),2)
    plot(year,pop,'o','MarkerFaceColor','r')
    hold on
    x=[0:0.01:6];
    y=exp(polyval(p,x));
    plot(x,y)
    hold on
    %part a
    %popluation at year 1900
    x1900=3
    %
    echo off; diary off
    What I am stuck at is how do I say I want the y value when x = 3?
     
  2. jcsd
  3. Nov 10, 2009 #2
    i just got finished with that problem, and mine is a little bit different than yours. for instance, on the polyfit lines, you don't need to make them quadratic, i just made mine linear. also, i didn't do parts a b and c because on the website (http://calclab.math.tamu.edu/~dmanuel/calclab/m151/Fall/2009c_matlab8.html) all it says is to use exponential fitting on the pairs of points. so it's a lot simpler than you're making it out to be. all in all, i got this:

    'delete s275x05.txt; diary s275x05.txt
    clear; clc; close all; echo on

    year=[0:1];
    pop=[728 906];
    p=polyfit(year,log(pop),1)
    plot(year,pop,'o','MarkerFaceColor','r')
    hold on
    x=[0:0.01:6];
    y=exp(polyval(p,x));
    plot(x,y)
    hold off

    year=[2:3];
    pop=[1171 1608]
    p=polyfit(year,log(pop),1)
    plot(year,pop,'o','MarkerFaceColor','r')
    hold on
    x=[0:0.01:6];
    y=exp(polyval(p,x));
    plot(x,y)
    hold off

    year=[3:4];
    pop=[1608 2517];
    p=polyfit(year,log(pop),1)
    plot(year,pop,'o','MarkerFaceColor','r')
    hold on
    x=[0:0.01:6];
    y=exp(polyval(p,x));
    plot(x,y)
    hold off

    year=[0:4];
    pop=[728 906 1171 1608 2517];
    p=polyfit(year,log(pop),1)
    plot(year,pop,'o','MarkerFaceColor','r')
    hold on
    x=[0:0.01:6];
    y=exp(polyval(p,x));
    plot(x,y)
    hold off

    echo off; diary off'
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook