%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % This script solves the dynamical system % % x(n+1) = f(x(n)) % % x(0) = A % % % % The user enters: % % the formula for function f (in file F1.m) % % the initial condition A (below) % % the number of iterations nmax (below) % % name of output file % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % feel free to change this stuff % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% nmax = 25; A = 0; outfile = 'out1.out'; x(1) = A; for n = 1:nmax x(n+1) = F1(x(n)); end fp = fopen(outfile, 'w'); for n = 1:nmax+1 fprintf('%3d %f\n', n-1, x(n)); fprintf(fp, '%3d %f\n', n-1, x(n)); end fclose(fp); plot(x, 'b-o'); xlabel('n'); ylabel('x(n)');