Project

stalagmite function

%finding the global maxima of a stalagmite function

clc
clear all
close all

%defining the search
x=linspace(-2,2,150);
y=linspace(-2,2,150);


%creating a 2D stalagmite functions
[xx yy] = meshgrid(x,y);

%Evaluating the stalagmite function 
for i=1:length(xx)
    for j=1:length(yy)
        input_vector(1)=xx(i,j);
        input_vector(2)=yy(i,j);
        f(i,j) = stalagmite(input_vector);
    end 
end

surfc(xx,yy,f)

shading interp
[inputs, fval]=ga(@stalagmite, 2);
globalmaxima=max(max(f))
for i=1:length(xx)
    for j=1:length(yy)
        if globalmaxima==f(i,j)
            xval=xx(i,j)
            yval=yy(i,j)
        end
    end
    end



function [G] = stalagmite(input_vector)

pi=3.14;
f1x=(sind((5.1*pi*input_vector(1)) + 0.5)).^6;
f1y=(sind((5.1*pi*input_vector(2)) + 0.5)).^6;
f2x=exp(-4*0.693147*(input_vector(1)-0.0667).^2/0.64);
f2y=exp(-4*0.693147*(input_vector(2)-0.0667).^2/0.64);

G= f1x*f1y*f2x*f2y;
end
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.