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

조회 수: 1 (최근 30일)
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!

채택된 답변

Jason Nicholson
Jason Nicholson 2014년 6월 17일
편집: Jason Nicholson 2014년 6월 17일
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
Jason Nicholson
Jason Nicholson 2014년 6월 18일
편집: Jason Nicholson 2014년 6월 18일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by