Why animated plot (using for loop) from a (sol) struct is too slow ?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I am solving the differential equations of a differential drive mobile robot using the ode23 solver and then plotting the results in an animated plot using a for loop. when i plot from
[t,s] = ode23(@Kpath, tspan, initials,[],p);
for j = 1:length(s(:,1))
q = plot(s(j,1),s(j,2),'ro','MarkerSize',5,'linewidth',1.5);
axis([-2.5 2.5 -2.5 2.5]);grid on;
pause(0.01)
delete(q)
end
the animation speed is normal however when i use the solution structure and then plot the results the animation is too slow ?
sol(i)= ode23(@mydglw4, tspan, initials,[],p);
initials = deval(sol(i),2);
t = linspace(0,2,100);
s = deval(sol(i),t);
is this related to the allocation of the struct ?
0 Commenti
Risposte (1)
Steven Lord
il 7 Mag 2017
You're creating one line per point, then almost immediately deleting it. Instead, I would use odeset to specify odeplot as the OutputFcn. If you have to plot after finishing solving the ODE, instead consider using an animatedline instead of creating and deleting lines for each individual point.
0 Commenti
Vedere anche
Categorie
Scopri di più su Numerical Integration and Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!