clear
%
%   Lorenz (Roessler) attractor
%
%   Files xd_lorenz.m and xd_roessler.m that contain the functions
%   must be in the same directory
%

global r;                               % define r as global variable

r=28;                                   % r value for strange attractor

figure('Position',[200 200 800 600]);   % create a figure

[t,xx]=ode45(@xd_lorenz,[0 50],[1 1 1]);    % from intitial condition [1 1 1] 
%[t,xx]=ode45(@xd_roessler,[0 50],[1 1 1]);  % integrate to t=50 (transient)
ll=length(xx);                              % last point in transient

[t,xyz]=ode45(@xd_lorenz,[0 100],xx(ll,:));    % integrate lorenz to t=100
%[t,xyz]=ode45(@xd_roessler,[0 300],xx(ll,:));   % integrate roessler to t=300

plot3(xyz(:,1),xyz(:,2),xyz(:,3));          % plot attractor in 3 dimensions

view(5,20);                                 % classic view for Lorenz
%view(-65,40);                               % classic view for Roessler


