function o = ps1(n, a1)
switch n
    case 1
        % Write a simple Matlab routine.  Compute the fibinacci number.
        % o should be the fibinacci number for a1.  Eg., fib(1) = 1, fib(2)
        % = 1, fib(3) = 2, fib(4) = 3, fib(5) = 5, ....
        o = fib(a1);
    case 2
        A = randi(7,6)
        % Create a 6x6 matrix with random numbers uniformly distributed
        % between 1 and 7.
        i = randi(7)
        o = matrix_replace(A, i, 0);
        % This will replace every instance of i in A with a 0.
    case 3
        tic;
        sum(a1(:));
        sumtime = toc;
        tic;
        o = myhist(a1);
        histtime = toc;
        histtime/sumtime
        figure;
        bar(o);
    case 4
        dname = input('Dir name: ');
        % Get from the user the name of a directory containing all images.
        files = dir([dname, '/', '*.jpg']);
        % We'll operate on all jpegs in the directory.
        for i = 1:length(files)
            I{i} = imread([dname, '/', files(i).name]);
            % Save all images in a structure.
        end
        histdist = [];
        for i = 1:length(I)
            i
            for j = 1:i-1
                j
                h1 = myColorHist(I{i});
                h2 = myColorHist(I{j});
                % This is wasteful, since I compute the histogram of each image twice.
                % You might want to fix this.
                histdist(i,j) = histDist(h1, h2);
            end
        end
        o = histdist; 
        
end

function o = matrix_replace(A, i, inew)
% Replace every i in A with inew.  
% You are not allowed to use any loops.
% Hint: take a look at "find"


function h = myhist(I)
% assume I is an image.
% Do not use the built in Matlab function hist.
