How to apply NonNegativity constraint in ODE solver when defining ode as a structure
이전 댓글 표시
I am trying to perform a local sensitivity analysis on the parameters of my model using odeSensitivity. Taking help from this page https://in.mathworks.com/help/matlab/ref/odesensitivity.html. but the problem is that when I used to code the ode simply I put nonnegativity under options, but now i am not able to do that. I tried taking F.NonNegative=ones(1,n_parameters) but that doesnt seem to work.
답변 (1개)
Steven Lord
2024년 8월 23일
0 개 추천
The relevant property of the ode object to specify that some of the variables must be non-negative is NonNegativeVariables. After you've set up that property, create the odeSensitivity object and set it to the ode object's Sensitivity property.
댓글 수: 7
Sayeeda
2024년 8월 26일
Torsten
2024년 8월 26일
I see four options that can be used with odeSensitivity (ParameterIndices, InitialValue, InitialSlope and Jacobian).
No NonNegative option available.
Sayeeda
2024년 8월 26일
NonNegativeVariables is a property of the ode object, not the odeSensitivity object. Using the example from the odeSensitivity documentation page with one addition:
p = [0.05 1.5];
F = ode(ODEFcn=@(t,y,p) [p(1)*y(1)-y(2); -p(2)*y(2)], ...
InitialValue=[2 3], ...
Parameters=p, ...
Sensitivity=odeSensitivity, ...
NonNegativeVariables = 2) % constrain the 2nd variable to be non-negative
Note that F has a Sensitivity property and a NonNegativeVariables property in its display. The NonNegativeVariables property probably won't do much (based on the picture in the example) as it looks like y(2) never becomes negative, but you can specify it.
S = solve(F,0,5)
As long as you can define your ODE function that accepts t, y, and p inputs and returns the right-hand side of your system of differential equations this approach should work.
Sayeeda
2024년 9월 1일
Steven Lord
2024년 9월 1일
Please send the code you're using to solve the system to Technical Support directly using this link. That way the development staff can investigate to determine if there is a bug in the sensitivity analysis code or if there's a modifiation required in your code.
Sayeeda
2024년 9월 2일
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!