-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logistic_Cot_Bifur.m
72 lines (64 loc) · 2.29 KB
/
Logistic_Cot_Bifur.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function mat = yue_bifur(fun,x0,a0,a1,N,L,p_siz)
% -------------------------------------------------
% By Yue Wu
% ECE Dept, Tufts University
% 03/03/2010
% All copyrights reserved
% -------------------------------------------------
% Function yue_bifur: plots 1D bifurcation figure
% Input: fun = some function @(x,para)
% x0 = initial value of x
% a0 = the start value of parameter a
% a1 = the end value of parameter a
% N = the number of intervals for parameter
% L = the number of iterations for each initial pair
% of (x0,parameter a)
% p_siz = the marker size, default 1
% Output: mat = bifucation matrix with size N by L
% which stores a length L sequence
% for each pair of (x0,parameter a)
%
% -------------------------------------------------
% Demo:
% fun = @(x,r) r*x*(1-x);
% x0 = .4; a0 = 0; a1 = 4; N = 100; L = 50;
% mat = yue_bifur(fun,x0,a0,a1,N,L);
% -------------------------------------------------Experiments-----
%fun = @(x,r) r*x*(1-x); % logistic map set a1=4
pai = 3.14;
%fun = @(x,r) r*sin(pai*x); %sin map set a1=1
%fun = @(x,r) cos(r*arccos(x)); %chebyshev map
x0 = 0.2; a0 = 0; a1 = 4; N = 1000; L = 50;
fun = @(x,r) mod(((r*x*(1-x))+(1+x)*(cot(pai*x))),1);
% default settings
if ~exist('p_siz','var')
p_siz = 2;
end
% initialization
mat = zeros(N,L);
a = linspace(a0,a1,N);
% main loop
format long
for i = 1:N
ca = a(i); % pick one parameter value at each time
for j = 1:L % generate a sequence with length L
if j == 1
pre = x0; % assign initial value
for k = 1:500 % throw out bad data
nxt = fun(pre,ca);
pre = nxt;
end
end
nxt = fun(pre,ca); % generate sequence
mat(i,j) = nxt; % store in mat
pre = nxt; % use latest value as the initial value for the next round
end
end
% plot
dcolor = [0,0,1]; % Marker color setting: blue
[r,c] = meshgrid(1:L,a); % associated cooridate data
surf(r,c,mat,'Marker','*','MarkerSize',p_siz,'FaceColor','None','MarkerEdgeColor', dcolor,'EdgeColor','None')
view([90,0,0]) % change camera direction
ylim([a0,a1]) % fit to data
ylabel('\mu')
xlabel('Xn')