Question
Modify the Matlab code below but of the same meaning. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Generate some output from the logistic map %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Time series %%%%%%% Output from the
Modify the Matlab code below but of the same meaning.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Generate some output from the logistic map
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Time series
%%%%%%% Output from the logistic map
%%%%%u_n+1 = r * u_n (1 - u_n)
%%%%%%
% r=0.8; % steady state
% r=1.2; % steady state
% r=2.2; % steady state
% r=3.2; % 2-cycle
% r=3.5; % 4-cycle
% r=3.55; % 8-cycle (may need to increase niters)
% r=3.6; % chaos
% r=4.0; % chaos
% r=3.83; % 3-cycle
% r=3.845; % 6-cycle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp(' ')
disp('This matlab code shows figures to the solutions to the logistic recurrence relation')
disp(' ')
disp(' u_{n+1} = u_n + r*u_n*(1-u_n)')
disp(' ')
disp(' ')
disp('Enter varying parameter "r"')
r=input ('r = ');
%
disp(' ')
disp('Enter the starting population point "u_0"')
u_0=input ('u_0 = ');
%
disp(' ')
disp('Enter the number of iterations:');
niters=input('(200) ');
if isempty(niters) niters=200;
end;
%
u_omega=u_0;
n=u_omega;
for i=1:niters; u_omega = u_omega + r*u_omega*(1 - u_omega);
n=[n u_omega];
end
%
% Plotting routine
plot([0:niters], n, 'k-*')
y_max = max([u_0 n]) + 0.1;
axis([0 niters 0 y_max]); grid on;
title(['logistic map with varying parametr r = ', num2str(r), 'K=1, ', 'and ' ,
'u\_0 = ', num2str(u_0)])
xlabel('Time n');
ylabel('Population u');
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started