Extracting unsolved data from ode45 function

Hi everyone,
I'm trying to create a aircraft model and i have differential equations
i have solved this equations with ode45 and i plotted the states which i want
But i want to plot the unsolved equations too(for example i have u v w from ode45 output but now i want to plot udot vdot and wdot)
How can i do that
Thanks

6 commentaires

can you just plug your u, v, w into the functions you have defined in the odefun (because they are just of the form du/dt, dv/dt, dw/dt, etc.)?
or are you asking for something else?
Use a for loop to provide your ODE function with the solved values and independent variable values in each iteration, and save the outputs. Those will be the derivatives.
That is yet another excellent answer from @Star Strider.
In case it is not obvious (and it was not obvious to me), he is sggesting that after your line
[t, vecste] = ode45(@(t,vecste)eom(t,vecste,spec,aero,thrust), tspan, stvecinit);
you do
dydt=zeros(size(vecste)); % allocate array
for i=1:length(dydt)
[~,dydt(i,:)]=eom(t(i),vecste(i,:),spec,aero,thrust);
end
Good luck!
Some minor corrections:
dydt = zeros(size(vecste)); % allocate array
dydt = dydt.';
for i=1:numel(t)
dydt(:,i)=eom(t(i),vecste(i,:),spec,aero,thrust);
end
Thank you @Torsten
Thanks to @Torsten @William Rose I appreciate.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Produits

Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by