% runme.m % Brad Poon & Les Fletcher % Math 164 Spring 2003 % Professor de Pillis % Last Modified: April 30, 2002 % % DESCRIPTION: % Script file to run population model and plot results. Just type 'runme' in MATLAB % to run the simulation and see results. % clear all; close all; % Initial population data based on data 2000 census data from the % Administration on Aging (http://www.aoa.gov/aoa/STATS/Census2000/2000-1990-Pop.html) iyoung = 1412; % Initial young population iadole = 1448; % Initial adolescent population iadult = 5897; % Initial adult population ielder = 1243; % Initial elderly population iresource = 5014113.4; % Initial resource level years = [1:300]; % Number of years to run simulation on % Solve the ODE using ode23 [t,y] = ode23(@populations, years, [iyoung,iadole,iadult,ielder,iresource]); % Get data for plotting and analysis young_pop = y(:,1); adole_pop = y(:,2); adult_pop = y(:,3); elder_pop = y(:,4); resources = y(:,5); total_pop = young_pop + adole_pop + adult_pop + elder_pop; % Plot of Individual Population vs. Time plot(t,young_pop,'r',t,adole_pop,'b',t,adult_pop,'g',t,elder_pop,'k',t,total_pop,'k:'); title('Population vs. Time'); xlabel('Time (years)'); ylabel('Population'); legend('Young','Adolescent','Adult', 'Elderly', 'Total Population',2) % Plot of Total Population vs. Time figure; timestep2 = young_pop + adole_pop; timestep3 = timestep2 + adult_pop; plot(t,young_pop,'r',t,timestep2,'b',t,timestep3,'g',t,total_pop,'k'); title('Total Population vs. Time'); xlabel('Time (years)'); ylabel('Population'); legend('Young','Young + Adolescent','Young + Adolescent + Adult', 'Total', 2) % Plot of Total Resources vs. Time iresource_level(1:length(years)) = iresource; % Initial resource level figure; plot(t, resources,'r', t, iresource_level, 'b'); title('Resources vs. Time'); xlabel('Time (years)'); ylabel('Resources'); legend('Resources',2) % Production and Consumption Rates ry1 = 77; % Resource production rate of 'Young' and 'Adolescent" age group ry2 = 103.6; % Resource consumption rate of 'Young' and 'Adolescent" age group rz1 = 820.1; % Resource production rate of 'Adults" age group rz2 = 774.3; % Resource consumption rate of 'Adults" age group re1 = 102.1; % Resource production rate of 'Elderly" age group re2 = 122.1; % Resource consumption rate of 'Elderly" age group % Critical resource values, amount of resources needed, amount resources available need = ry2.*(y(:,1)+y(:,2)) + rz2.*y(:,3) + re2.*y(:,4); availibility = y(:,5); % Plot of availability of resources and need for resources vs. time figure; plot(t, need,'r', t, availibility, 'b'); title('Availability of Resources and Need for Resources vs. Time'); xlabel('Time (years)'); ylabel('Resources'); legend('Need', 'Availibility' ,2)