Back Submit a hand
Handnr: 156437 Submitted by : Gastjuh
% lorenzdriver.m
% this file sets the parameters and initial conditions,
% calls oderk, and makes plots
global b sig r % make the parameters global
b = 8/3; % set the parameters
sig = 10;
r = 28;
x0 = [0; 1; 0]; % initial conditions of state vector
t = 0:0.01:50; % [0 0.01 0.02 ... 50]
fname = 'lorenzrhs'; % the name of the rhs file (.m is assumed)
[t,x] = oderk(fname,t,x0); % turn the work over to oderk
plot3(x(:,1),x(:,2),x(:,3));% make a 3-d plot (cool!)
xlabel('x'); % add some labels
ylabel('y');
zlabel('z');
title('Sample Runge-Kutta Solution of Lorenz System');
The right-hand side ¯le is quite simple.
% lorenzrhs.m
% xdot = rhs(t,x)
function xdot = rhs(t,x)
global b sig r
xx = x(1); % the x component
y = x(2); % and y ...
z = x(3);
xdot = [ sig*(y-xx); -xx*z+r*xx-y; xx*y-b*z];
% that's all!
|
Comments |
|
1
|
KingKory   United States. Mar 09 2007 12:20. Posts 2083 | | |
|
| |
|