-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbif7.m
53 lines (41 loc) · 955 Bytes
/
bif7.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
%% Animation for a zoomed in saddlenode bifurcation
xmin = -0.5;
xmax = 0.5;
x = xmin:0.001:xmax
ax = (0.0).*x;
rmin = 1-0.2
rmax = 1+0.2
imax = 21
ymin = -0.5;
ymax = 0.5;
ky = ymin:0.1:ymax
ay = (0.0).*ky
for i = 1:imax
%calculate r value
r = rmin + (i-1)*(rmax-rmin)/(imax-1)
%create title string
strr = num2str(r);
strt = ['r=' strr];
%calculate dxdt
y = r - x - exp(-x);
%plot x-axis
plot(x,ax,'--');
axis([xmin xmax ymin ymax])
hold on
%plot y-axis
plot(ay,ky,'--')
%plot f(x)
plot(x,y,'r');
%plot labels
xlabel('x','FontSize',20)
ylabel('dx/dt','FontSize',20)
text(-0.3,0.4,'dx/dt = r - x - e^{-x}','Color','r','FontSize',20)
text(0.3,0.4,strt,'FontSize',20)
%getframe
h = gcf;
M(i) = getframe(h,[5 5 480 380]);
hold off
end
%play and save movie
movie(M);
movie2avi(M,'Graphbif3','fps',2);