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 Kommentare

J. Alex Lee
J. Alex Lee am 22 Sep. 2023
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?
Star Strider
Star Strider am 22 Sep. 2023
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
William Rose
William Rose am 22 Sep. 2023
Thank you @Torsten
Thanks to @Torsten @William Rose I appreciate.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by