Actions

Sayres logstic M-code: Difference between revisions

From Santa Fe Institute Events Wiki

(pasting in code I wrote to play with lecture concepts)
 
mNo edit summary
Line 1: Line 1:
<code>
function X = logistic(R, N, X0);
function X = logistic(R, N, X0);
% Compute the logistic equation given a control parameter R,  
% Compute the logistic equation given a control parameter R,  
Line 18: Line 19:


return
return
</code>

Revision as of 20:02, 2 June 2008

function X = logistic(R, N, X0); % Compute the logistic equation given a control parameter R, % a number of iterations N and an initial state X0. % % X = logistic(R, [N=10], [X0=0.5]); % % % ras, 06/02/08. if nargin < 1, error('Need conrol param R'); end if notDefined('N'), N = 10; end if notDefined('X0'), X0 = 0.5; end

X(1) = X0;

for n = 2:N X(n) = R * X(n-1) * (1 - X(n-1)); end

return