Printing all outputs of the function that has been solved via ode45
Mostra commenti meno recenti
I have defined a function to be solved using ode45. The function is called endoFlightDeriv
function [deriv, m, h] = endoFlightDeriv(t, X, E, L,phaseCode)
Then I solve it using ode45
[time_vert,sol_vert]=ode45(@(t,x)endoFlightDeriv(t,x,E,L,PhaseCode),tspan,x0,options)
My question is, how can I output the values of m and h at each integration step?
This is the first question that I ever post, so I apologize in advance if this is not clearly stated. Obviously I can further explain my problem.
4 Commenti
It appears to be an endo-atmospheric flight mission. My assumption is that 'm' represents the mass of the vehicle, while 'h' denotes the height of the vehicle. Is the system described in linear state-space?
Could you please show the output functions 'm' and 'h'? It would be beneficial to understand the parameters and state variables that are involved in these functions.
Niccolo Carioli
il 26 Mar 2024
Sam Chak
il 26 Mar 2024
No worries. I believe your specific technical issue in MATLAB has been resolved and closed. However, it's worth noting that there are at least six approaches available to achieve this, depending on the complexity of the output functions involved.
Niccolo Carioli
il 26 Mar 2024
Risposta accettata
Più risposte (1)
Torsten
il 26 Mar 2024
Assuming m and h are scalars, use
[time_vert,sol_vert]=ode45(@(t,x)endoFlightDeriv(t,x,E,L,PhaseCode),tspan,x0,options)
for i = 1:numel(time_vert)
[~, m(i), h(i)] = endoFlightDeriv(time_vert(i), sol_vert(i,:), E, L,phaseCode)
end
If not, change the loop appropriately.
1 Commento
Niccolo Carioli
il 26 Mar 2024
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!