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!