Homework question I don't understand

1 Ansicht (letzte 30 Tage)
Celeste Knight
Celeste Knight am 23 Jan. 2015
Bearbeitet: Celeste Knight am 24 Jan. 2015
I've been given this homework problem that involves finding the range of the initial value for the number of the population infected in a week for some disease spread. I don't quite understand how to go about answering the question and translating it in code. Attached is the homework problem pdf and below is what I came up with so far (I know this code doesn't work)
for n=1:100
R=(x(n+1)^2)/x(n)-((x(n))^2);
(0<x(1))&&(x(1)<1);
x(n+1)=R*x(n)*(1-x(n));
end
plot(x)

Antworten (1)

Daniel Vasilaky
Daniel Vasilaky am 24 Jan. 2015
Bearbeitet: Daniel Vasilaky am 24 Jan. 2015
Look at the plot for various x and R. Remember that R=4.6692016091 is a critical point. For example, if say x=.02 and R=4<4.6692016091 , we get unstable plot. For R=1 we smoothly converge to 0. Here is the code for x=.02 and R=4.
x=.02; % initialize x
for i=1:100, %loop say 100 times
x=4*(x-x^2); % Set R=4,this is the recurrence x_i+1=4*(x_i - x_i^2)
t(i,1)=i;% store i in the first column of 100-by-2 matrix
t(i,2)=x;% store x in the second column
end;
plot(t(:,1),t(:,2)); % plot the 1st column vs. 2nd column.
It's a start, hope it helps.
  1 Kommentar
Celeste Knight
Celeste Knight am 24 Jan. 2015
Bearbeitet: Celeste Knight am 24 Jan. 2015
how exactly did you find R in the first place? and when i try to edit my code to what you have posted i just get an error

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by