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

2 views (last 30 days)
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!

Accepted Answer

Jason Nicholson
Jason Nicholson on 17 Jun 2014
Edited: Jason Nicholson on 17 Jun 2014
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 Comments
Jason Nicholson
Jason Nicholson on 18 Jun 2014
Edited: Jason Nicholson on 18 Jun 2014
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.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!