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
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
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
2023-9-22
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
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
2023-9-22
Thank you @Torsten
Muhammed Emin Yavuzaslan
2023-9-25
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!