-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathphase3.m
50 lines (40 loc) · 946 Bytes
/
phase3.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
function phase3(o,ti,ax)
%
% phase3(o,ti,ax)
%
% Phase portrait of 3D o.d.e. given in file o
% ti - time interval (default 200)
% ax - axis info for plot
%
% Use keyboard to input initial data
%
% See also PHASE
if nargin < 2, ti = 200; end
if nargin < 3, ax = 4 * [-1 1 -1 1 -1 1]; end
colors = ['b','g','r','c','m','y'];
ncolors = size(colors,2);
ic = 1;
tso = ti; ts = [0 tso];
clf;
gax = axes;
axis(ax);
rotate3d;
stopit = 0;
while stopit == 0
id = input('Initial Data : ');
if size(id) == [1 3]
x0 = id(1); y0 = id(2); z0 = id(3);
idfl = 1;
else
disp('Initial data must be row vector with 3 entries');
idfl = 0;
end
if idfl == 1
u0 = [x0 y0 z0]';
[t,y] = ode23(o,ts,u0);
hold on; plot3(y(:,1),y(:,2),y(:,3),colors(ic)); hold off;
[t,y] = ode45(o,-ts,u0);
hold on; plot3(y(:,1),y(:,2),y(:,3),colors(ic)); hold off;
ic = ic + 1; if ic > ncolors, ic = 1; end
end
end