MATLAB: How to plot the velocity and acceleration vectors at only every 10th computation of position? I have 10’000 computations of position. Two vectors at every point provides a messy and unuseful plot. Thanks!

MATLABplotquiver3vectorsvelocity

Best Answer

N=10; % how many points in interval
ix=1:N:length(xp); % indexing vector of every N-th point
...
quiver3(xp(ix), yp(ix), zp(ix), xa(ix), ya(ix), za(ix), 'm');
...
Could also write as
quiver3(xp(1:N:end), yp(1:N:end), zp(1:N:end), xa(1:N:end), ya(1:N:end), za(1:N:end), 'm');
instead of precomputing the index vector; for graphics probably no real efficiency gained but it's a bunch of the same thing explicitly vs the one; your choice.
Clearly could use a second M for the other plot and/or start from some initial index than 1 for one or the other so points aren't the same between the two...so many choices... :)
Read up on
doc colon % for additional info as well as the end keyword as indexing expression