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 commentaires

Please post the symbolic portion of the code.
Here are the live scripts where im defining the equations in. The model is divided into a modular structure i.e scripts for the chassis, the wheels, the suspension and the tire-road contact. In text.mlx im collecting all the forces, substituting out some parts and then attempting to create the function handle. Please excuse the untidy nature of test.mlx - i just wanted to get everything up and running.

Connectez-vous pour commenter.

Réponses (1)

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 commentaire

Hi Umar,
after thinking about my problem a bit, I came to the same conclusion. I tried to avoid the manual construction of the function handle because the system of equations is very large and complex but I cant think of an automatic solution.
Thanks for your help.

Connectez-vous pour commenter.

Produits

Version

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by