find local minima with range for inputs
Show older comments
I am trying to find the minima for a function for which I pass 5 values. However I cannot get the function to apply my parameters. This is what I have so far:
My objective function is:
function q = my_objective_function(m1,m2,m3,m4,m5)
q = sqrt(pi*30*6.5*(10^-6).*(m3.*m5/((2.*(m2.^(3/2)).*(m4.^(1/2))))+(((m1+m2).*(m4.^2))/(2.*m5.*(m2.^2)))));
end
I have set the parameters for m1...m5 in the command line as follows:
>>m1 = 30:1:100
%so I have a range for m1 to be from 30 to 100 in 1 increments
%I have done similar for the other 4 m's
In the command window I then write:
>> [x, fval] = ga(@(m)my_objective_function(m(1),m(2),m(3),m(4),m(5)),5)
but my answers still give values that are out of range, for example:
x =
-18.6531 65.5402 -12.9160 9.6649 11.4359
fval =
0.0000e+00 + 3.4396e-04i
How do I apply my parameters for my m's correctly?
Answers (1)
Walter Roberson
on 27 Jan 2019
nvar = 5'
A = []; b = [];
Aeq = []; beq = [];
lb = 30 * ones(1,nvar);
ub = 100 * ones(1,nvar);
nonlcons = [];
Intcons = 1:nvar;
[x, fval] = ga(@(m)my_objective_function(m(1),m(2),m(3),m(4),m(5)), nvar, A, b, Aeq, beq, lb, ub, nonlcons, Intcons)
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!