Week 4.1 - Genetic Algorithm
based on the question i received
i started the program in function camman
in this function command i taken the varuables as x,y
and the given function equations as f1,x;f1,y;f2,x;f2,y
Y(1,x)= sin((5.1*pi*x)+0.5).^6;
Y(1,y)= sin((5.1*pi*y)+0.5).^6;
Y(2,x) = exp(-4*log(2)*(x-0.0667).^2/0.64);
Y(2,y) = exp(-4*log(2)*(y-0.0667).^2/0.64);
before ending the function i given the value of pi as 3.14
and ended the function
and this function is used as the sub program for tjhe main function
after entering into the main function the values of x and y cordinates are given in the linspace
x=linspace(0,0.6,150);
y=linspace(0,0.6,150);
later used the comandof the meshgrid it is used as the 3d cordinates with grid size
in the meshgrid command used the x and y cordinates to use in the coomand as and asigned to the xx and yy coordinates
[xx,yy]=meshgrid(x,y)
later used the for loop for the meshgrid
in the for loop length of the i is asigned to xx
later taken the another for loop as j command
and length of j is asigned to the yy
this asigned i and j values are asigned to the sub function variables as
for i=1:length(xx)
for j=1:length(yy)
variable_trigonmetry(1)=xx(i,j);
variable_trigonmetry(2)=yy(i,j);
end
end
and the function is asigned to the stalagmite
stalagmite is a variable which can be used for the multi variable function
in the for loop i asifned with the i and j cordinates as
stalagmite= variable_trignometry(i,j);
surfc command is used for the counter function where we can used for the contiuning the loop and to add the value but n the surface of the loop command
later uses the genatic alogarithm
this alogrithm is used to find the generation and from this generation is used to find the best result and can be used to find the maximum value using the lowe boundarys and higher boundaries and the equationss are given to find the best result that is higest peak value of the x y and z cordinates
the maximum value of the function can be determined from the equation as keeping it in negative we can find the maximum value of the function
the command pf ga as @functionequation,and lower boundaries and higher boundaries,and aequation and bequation
this are used and the number of variables are used as to be enter
ERROR FOUND
while doing the function variable i found the error in the placing the power of the equation and vector multiplication
in writing the program found the difficulites in using the function program in the main command
fval cannot be dtermined by the function
In the end of the function unable to determine the stalagmite function
unable to plot the graph graph for the maximum and itration
ERROR CORRECTION
it vector multplication was given in the command window
it was explained by the command window ias the invaild variable

