Question

Solve the following utilizing MATLAB code. must provide the inputs and outputs of the function. the function should be able t
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code: populationestimator.m

clc
clear

t0 = 1950;
p0 = 2555;
tEnd = 2000;
h = 10;
N  = (tEnd - t0)/h;
%% Initializing solution
t = [t0:h:tEnd]';
p = zeros(N + 1, 1);
p(1) = p0;

%% Ploting given data
pg = [2555 3040 3708 4454 5276 6079];
plot(t, pg, 'ko');
hold on
%% Solving using Euler's Explicit Method
for i = 1:N
    fi = funp(t(i), p(i));
    p(i + 1) = p(i) + h*fi;
end

plot(t, p, 'r-');
legend('given data', 'simulation result');

Code: funp.m

function dp = funp(t, p)
kgm = 0.026;
pmax = 12000;
dp = kgm * (1 - p/pmax)*p;
  
end

Output:

6500 O given data simulation result | Ф 6000 5500 5000 4500 4000 3500 3000 2500 1950 1955 1960 1965 1970 1975 1980 1985 1990

Add a comment
Know the answer?
Add Answer to:
Solve the following utilizing MATLAB code. must provide the inputs and outputs of the function. the function should be able to solve such problem using Eulers method, in which after solving must p...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MUST USE MIDPOINT METHOD AND ANONYMOUS FUNCTION and MATLAB, no outer function please. Will rate answer 5 stars if done...

    MUST USE MIDPOINT METHOD AND ANONYMOUS FUNCTION and MATLAB, no outer function please. Will rate answer 5 stars if done right :) Solve using the midpoint method (RK2), choose a step size The logistic model is used to simulate population as in: Pmax where p -population, kgm -the maximum growth rate under unlimited conditions, and pmax - the carrying capacity. Simulate the world's population from 1950 to 2000 using one of the numerical methods described in this chapter. Employ the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT