How to minimize [sum of four equations] when I have their differential equations with two variables

Hello, I'm trying to solve four differential equations. Each differential equation has two variables a and b (not x). My goal is finding out the values of variables( a and b) when [sum of four equations] is minimum using fmincon. The ranges for a and b are 0<a<100 and 0<b<22. So I set up sumofthem=y(1)+y(2)+y(3)+y(4) and fmincon(@sumofthem,[].....). But actually in 'sumofthem', there is no term about a and b so I couldn't put the conditions(such as UB)about a and b in fmincon. Moreover, I don't know how to vary a and b to solve differential equations, not to put individual numbers for them. Does anyone give me an advice? Thank you!

 Respuesta aceptada

This is a prime candidate for "grey box" modeling with the "System Identification Toolbox" which has a nice GUI.
If you want to use fmincon use the following:
ab0 = [1; 1]; % initial guess
A = [ 1 0; % a<100
-1 0; % a>0
0 1; % b<22
0 -1];% b>0
b = [100*(1-eps); % a<100
0-eps; % a>0
22*(1-eps); % b<22
0-eps]; % b>0
ab = fimcon(@sumOfThem, ab0, A, b);
a = ab(1);
b = ab(2);

4 comentarios

If this answers your question, please mark this as the correct answer. It helps my reputation points on MATLAB answers.
Thank you, Jason! It's really helpful to me. Can I ask why 'eps' is needed in b instead of just b=[100;0;22;0]?
Your requirements were the following
0 < a < 100
0 < b < 22.
If they were
0<= a <= 100
0<= b <= 22,
then I would have not used eps.
100*(1-eps) is the number closest to 100 but still less that can be represented by a double. Using this form lets a, for instance, get really close to 100 but it will never equal 100.
In general, this is a small difference. It really doesn't matter most of the time.
I got it! Thank you so much!!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 17 de Jun. de 2014

Comentada:

el 18 de Jun. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by