Respuesta aceptada

Star Strider
Star Strider el 11 de Dic. de 2017

0 votos

The optimisation routines need vector input for the parameters. I combine them as vector ‘p’ here.
Try this:
x0 = [0.5; 500];
[x, fval] = fmincon(@(p) -launch(p(1),p(2)), x0, [],[],[],[], [0.11 15], [1 1310])
Note that the optimisation functions minimise the function output, so to maximise it, you need to negate the the function.
When I ran your function, I got:
x =
893.8695e-003
473.4764e+000
fval =
-38.4141e+000
So ‘m2=0.89’, ‘k2=473’, producing a distance of 38.4.
You may need to experiment to get the result you want. See the documentation for fmincon for details on what it can do.

2 comentarios

Star Strider
Star Strider el 11 de Dic. de 2017
Walle Walhood’s Answer moved here —
So, the fval is a negative number.? is there a way to limit the output make sure it is a positive number?
Also, thank you very much for your help
Star Strider
Star Strider el 11 de Dic. de 2017
My pleasure.
Since I negated the function in order to maximise it, fval will be negative. Just remove the minus sign to get the correct result.
If my Answer helped you solve your problem, please Accept it!

Iniciar sesión para comentar.

Más respuestas (1)

Walle Walhood
Walle Walhood el 11 de Dic. de 2017

0 votos

I sure will, Thanks again!

1 comentario

Star Strider
Star Strider el 11 de Dic. de 2017
As always, my pleasure!
Also, you can run your function with the optimised variables to get the ‘positive’ distance.

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 11 de Dic. de 2017

Comentada:

el 11 de Dic. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by