how to minimize a function using Genetic Algorithm in matlab
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have the following code with function Y = 1000*log(1+4.5/((100-u*cos(theta)*(X))^2+(100+u*sin(theta)*X-4.9*...
(X)^2)^2));
I want to minimize this using GA optimtool. How could I do this because my function is calculated in a loop. So, how could I use the whole code as fitness function?
a = 0;
b = 6;
B = 1000;
u = 40;
theta = pi/12;
Int_simp = zeros(1,10);
disp(Int_simp);
for N = 1:10
sum_simp = 0;
dx=(b-a)/N;
for r = 1:N
X = a + ((r-1)*dx);
Y = 1000*log(1+4.5/((100-u*cos(theta)*(X))^2+(100+u*sin(theta)*X-4.9*...
(X)^2)^2));
if (mod(r,2) == 0)
coeff = 4;
else
coeff = 2;
end
if (r == 0)||(r == N)
coeff = 1;
end
sum_simp = sum_simp + (coeff*Y*dx*(1/3));
end
Int_simp(N) = sum_simp;
end
plot(Int_simp,'-sm');
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!