daeFunction() automatically removes state variables in resulting function handle
이전 댓글 표시
Hi,
I implemented a 14 DOF dynamic Two-Track Model with 36 states variables in form of symbolic differential equations and i want to create a function handle from these equations so i can solve the model numerically. I already tried to use the function odeToVectorField() with no success because the model equations are non-linear. Applying the function reduceDifferentialOrder() and then daeFunction() worked but the resuting function handle is missing some state variables in its function body. Im appending the output of reduceDifferentialOrder() and daeFunction() below as .mat or .m file respectively.
Are there any other methods, to programmatically create the function handle, that im missing?
Best wishes,
Tim
댓글 수: 2
Walter Roberson
2024년 7월 1일
Please post the symbolic portion of the code.
Tim Reminder
2024년 7월 2일
답변 (1개)
Umar
2024년 7월 2일
0 개 추천
Hi Tim,
In my opinion, to resolve your issue, you can use an alternative approach by manually construct the function handle. By defining the differential equations explicitly in a function, you can ensure all state variables are included. Here's a simplified example:
function dydt = myODEs(t, y)
% Define your differential equations here
% Example: dydt = y(1)^2 - y(2);
dydt = zeros(numel(y), 1); % Initialize dydt
% Assign equations for each state variable
dydt(1) = y(1)^2 - y(2);
% Add equations for other state variables as needed
end
Afterwards, use this custom function myODEs with Matlab's ODE solvers like ode45 or ode15s. This method gives you full control over the equations and ensures all state variables are accounted for in the function handle.
Hope this will help resolve your issues.
카테고리
도움말 센터 및 File Exchange에서 Equation Solving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!