Homework question I don't understand

2 次查看(过去 30 天)
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)

回答(1 个)

Daniel Vasilaky
Daniel Vasilaky 2015-1-24
编辑:Daniel Vasilaky 2015-1-24
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 个评论
Celeste Knight
Celeste Knight 2015-1-24
编辑:Celeste Knight 2015-1-24
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by