

%==========================================================================
%REU Tutorial:  (Example Two)
%
%files_example.m
%
%Simple use of mfiles and functions.  Simple loops and plots.
%
%Dependencies: This program depends on the function `logisticMap.m`,
%              which must be in the current working directory in order 
%              for the program to execute.
%==========================================================================


clear
format long

%An mfile is just a script file of matlabl commands.  Using mfiles saves
%lots of time if you are working on a long computation which you may want
%to run many times.

%Logistics Map
    %simulation time:
    tf = 100
    
    %Time axis
    t=linspace(1, tf, tf);

    %initial condition
    x(1)=0.7;

    %iterate the map
    for n=1:(tf-1)
        x(n+1) = logisticMap(x(n), 2.75);
    end %end of n's for loop    

    %plot the result
    figure
    plot(t(:),x(:))
    xlabel('time axis','FontSize',8)
    ylabel('population','FontSize',8)
    title('An orbit of the logistical map','FontSize',10)
    %h = legend('x', 1)
    %axis([0 100 -50 50])
    
    
    
    
    
    
    
