Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: plot problem
Replies: 6   Last Post: Dec 2, 2012 11:21 AM

 Messages: [ Previous | Next ]
 Sanaa Posts: 171 Registered: 3/20/12
Re: plot problem
Posted: Dec 2, 2012 11:21 AM

Thanks a lot for explanations. I have tried my own code to plot the bifurcation diagram but still have one problem

% define the vector of colors, to plot the dat aof reach value of r in
% different color
color_vec = ['b'];
r=0.05;
for rho = 0: 0.001:10

% do a loop of values of r
for j = 1 : size(r_vec,2)
% define delay
r = r_vec(j);
% define coefficient rho
%rho = 0.5;
% define the number of deiscrete times in interval [k*r, (k+1)*r]
n = 50;
% define the nimber of iterations k = 1,.....,Nit
Nit = 300;
% define the initial vector which is a vector of size n
x0 = 0.3*ones(1,n);
% define vectors x_next and x_previous
x_next = zeros(1,n);
x_previous = zeros(1,n); %x_n
x_pp=zeros(1,n); %x_n-1
x_ppp=zeros(1,n); %x_n-2
x_pppp=zeros(1,n); %x_n-3
time = zeros(1,n);

% initialize x_previous
x_previous = x0;
x_pp=0.2*ones(1,n); %x_n-1
x_ppp=0.1*ones(1,n); %x_n-2
x_pppp=0.4*ones(1,n); %x_n-3
time = zeros(1,n);
%x_next = x_previous;
time = linspace(0,r,n);

hold on
for i = 1:Nit
time = linspace(i*r,(i+1)*r,Nit);
x_next = x_previous+(time(i)-i.*r_vec(j))*rho*x_pppp.*(1-x_ppp);
x_previous = x_next;
end
end
plot(rho,x_next(1),'.', 'Color', char(color_vec(j)))

end

I always get a straight line. What went wrong please?
Thanks a lot for your help. I really appreciate it.

Date Subject Author
11/27/12 Sanaa
11/27/12 Nasser Abbasi
11/28/12 Sanaa
11/28/12 Nasser Abbasi
11/28/12 Sanaa
11/28/12 Nasser Abbasi
12/2/12 Sanaa