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 件のコメント

J. Alex Lee
J. Alex Lee 2023 年 9 月 22 日
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 2023 年 9 月 22 日
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.
William Rose
William Rose 2023 年 9 月 22 日
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!
Torsten
Torsten 2023 年 9 月 22 日
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 2023 年 9 月 22 日
Thank you @Torsten
Muhammed Emin Yavuzaslan
Muhammed Emin Yavuzaslan 2023 年 9 月 25 日
Thanks to @Torsten @William Rose I appreciate.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by