how to minimize a function using Genetic Algorithm in matlab

조회 수: 1 (최근 30일)
Indu Choudhary
Indu Choudhary 2020년 3월 12일
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개)

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by