using control constraints in ode45
이전 댓글 표시
I need to use ode45 to solve a system of simultaneous differential equations that must meet a constraint on a function of a couple of its variables (this is part of a control system on which there is a control constraint). I can’t find any help documentation that provides for this situation so I assume that it can be done manually. This means that I need to check the value of an expression that is a function of a portion of the solution vector at every time and step, and if it exceeds a constraint, I’ll need to recalculate that particular time step of the numerical integral. Without understanding the nuances of the underlying computations in ode45 it’s hard to tell how I should do that. Anyone know how?
Could I just rewrite the new system after checking the condition and ode45 will handle it correctly?
For example:
%the original system
%epsilon is a constant and ms and bs are computed before the following
dydt(1) = y(2);
u = -(2*epsilon^2*ms'*bs*y(2)^2+y(4))/(2*epsilon^2*ms'*ms);
dydt(2) = u;
dydt(3) = 0;
dydt(4) = -4*epsilon^2*(bs'*bs*y(2)^3+ms'*bs*y(2)*(-(2*epsilon^2*ms'*bs*y(2)^2+y(4))/(2*epsilon^2*ms'*ms)))-y(3);
%check for violation of constraint
u=f(y(1),y(2),y(3)
If (u >= constant)
u=constant
% constraint is violated, solve new system with constraint
dydt(1) = y(2);
dydt(2) = u;
dydt(3) = 0;
dydt(4) = -4*epsilon^2*(bs'*bs*y(2)^3+ms'*bs*y(2)*(-
(2*epsilon^2*ms'*bs*y(2)^2+y(4))/(2*epsilon^2*ms'*ms)))-y(3);
end
Basically what I need to know is how to make ode45 reiterate a step and use a different set of equations. There must be someway to impose constraints like this, maybe I missed it in the help files….
My question is similar to what someone is trying to do here: ( http://www.mathworks.com/matlabcentral/answers/14164-using-saturated-inputs-in-ode45), they have implemented the constraint before the set of differential equations which I think is incorrect due to the fact that his control inputs should be a function of the current states, not the ones from the last state….
Can anyone help me please?
Thanks,
Kyle Stanhouse
댓글 수: 4
Jan
2012년 1월 15일
Please format your code as explained in the "Markup help" link on this page.
Kyle Stanhouse
2012년 1월 16일
Walter Roberson
2012년 1월 16일
http://www.mathworks.com/matlabcentral/answers/help/markup
http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
yosra welhazi
2015년 4월 9일
Dear friend;
I have the same problem as you and when I simulate and plot my control inputs, they are not saturated , what can I do please
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!