How to save ode45 outputs in a loop?
Afficher commentaires plus anciens
I am trying to save my T and Y values in a loop, but it gives me the error "Subscripted assignment dimension mismatch."
I originally had [T,Y] = ode45(dydt, t, [y0, dy0], options); but it would only save when j = 7.
Help please?
for j = 1:7
[T(j),Y(j)] = ode45(dydt, t, [y0, dy0]);
end
Réponse acceptée
Plus de réponses (1)
James Tursa
le 9 Oct 2019
Modifié(e) : James Tursa
le 9 Oct 2019
Don't use a loop. Just call ode45 once and it will give you the entire results in T and Y.
[T,Y] = ode45(dydt, t, [y0, dy0]);
If you want outputs at specific times, set t accordingly. E.g.,
t = linspace(0,5,100);
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!