% to generate time series data for Lorenz equations
% 

% setting up the environment
% clearing the memory, closing all the figures (graphs)
% clearing command prompt
%
clear all;
close all;
clc;

% setting up the initial values to be taken for the lorenz model
%
x = 10;
y = -5;
z = -10;

% picking up dummy variables to be used in a loop
%
x1 = x;
y1 = y;
z1 = z;

% setting up the equation constants so that the chaotic behavior is seen
%
sigma = 16;
r = 40;
b = 4;

% the sampling interval
%
dt = 0.01;
num_samples = 49000;

% we are drawing 49000 samples for the Lorenz model
%
for i=1:num_samples

    % setting up the difference equations 
    % to get the incremental rise in x, y, z
    % 
    dx = sigma * (y1 - x1) * dt;
    dy = (r * x1 - y1 - x1 * z1) * dt;
    dz = (-b * z1 + x1 * y1) * dt;
    
    % adding the increment to the previous value
    %
    x1 = x1 + dx;
    y1 = y1 + dy;
    z1 = z1 + dz;
    
    % appending the value to the array
    % 
    x = [x; x1];
    y = [y; y1];
    z = [z; z1];

end;

% just to have a chaotic plot for the Lorenz model
% 
plot(x, y);

% as the file carries name, hence one more addition
% we are saving time series data for x variable
%
lorenz_data_v00 = x;
save lorenz_data_v00;
