%Demonstrate gradient descent

method = 'square'; %possibilities earth, square
visualization = 3; %possibilities: 0 (no visualization), 2 (2D visualization) 3 (3D)
%in case of earth, it worths to set GradientDescent to maximiazition and to
%set alpha to 10

if strcmp(method,'square')
    f = @(x,y)(3.*x.^2 + y.^2);
    [X,Y] = meshgrid(-5:0.1:5);
    Map = f(X,Y);    
    start = [1,1];
elseif strcmp(method,'earth')
    load topo;
    Map = topo;
    start = [97,93];
end

GradientDescent(Map,start,visualization)
