daeFunction() automatically removes state variables in resulting function handle
Ältere Kommentare anzeigen
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 Kommentare
Walter Roberson
am 1 Jul. 2024
Please post the symbolic portion of the code.
Tim Reminder
am 2 Jul. 2024
Antworten (1)
Umar
am 2 Jul. 2024
0 Stimmen
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.
1 Kommentar
Tim Reminder
am 2 Jul. 2024
Kategorien
Mehr zu Equation Solving finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!