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
回答(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!