% mg.m: Mackey Glass generator tt = 6; % sampling rate dt= 0.01; % inegrate step NN = 600*tt/dt % final number of samples tau = 30/dt; % Mackey-Glass paramater x = .9*ones(NN+1,1); % initial conditions % Runge-Kutta Method for n = tau+1:NN, xx = x(n); xxd = x(n-tau); xk1 = dt*mg1(xx,xxd); xk2 = dt*mg1(xx+xk1/2,xxd); xk3 = dt*mg1(xx+xk2/2,xxd); xk4 = dt*mg1(xx+xk3,xxd); nn = n+1; x(nn) = xx + xk1/6 + xk2/3 +xk3/3 +xk4/6; end % resample every tt/dt y = x(1:tt/dt:NN); %function [mgx] = mg1(x,xd) %mgx = -0.1*x + .2*xd/(1+xd^10); %Eric Wan %Associate Professor %OGI School of Science and Engineering, OHSU %Phone: 503-748-1164 Fax: 503-748-1548 %http://www.cse.ogi.edu/~ericwan/