How to animate line on polar axes plots
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mark Duarte
el 5 de Sept. de 2018
Comentada: dpb
el 7 de Sept. de 2018
I'm trying to animate a plot with polar coordinates, ideally to trace a line following a marker. I've tried using the animatedline object but it doesn't seem to take polar coordinates. This is the code I've tried
figure
pax = polaraxes;
pax.RLim = [0, 6];
pax.ThetaDir = 'clockwise';
animatedline(pax, theta, r);
But get the error:
Error using animatedline
AnimatedLine cannot be a child of PolarAxes.
I've also tried iterating with a for loop and polarplot with a "hold on" but it seems super choppy. Any ideas is appreciated.
0 comentarios
Respuesta aceptada
dpb
el 5 de Sept. de 2018
Editada: dpb
el 6 de Sept. de 2018
polar coordinates are "red-haired stepchildren" in Matlab, for sure.
I've not played with the new(ish) PolarAxes, but I think if you simply first create a line handle with the initial point, you can then update the ThetaData, Rdata properties of the line directly. There's an example of a marker following a line at Trace-marker-along-line for a single point; to draw a line you simply add data points to the internal arrays; remember to preallocate an array of NaN for performance instead of dynamically reallocationg by concatenation.
The newer documentation links make the above hard to find; if didn't know it had existed in earlier versions, not sure one would ever find it. I had to do a search for "Animation" to uncover the link. The only thing at the top level I did find took me to the animatedline which we know doesn't work completely universally yet.
NB: EDITORIAL COMMENT/OPINION
TMW gets so enamored with all their new toys they often seem to introduce them before they're fully ripe which is OK if they don't sever the documentation links to the tried-and-true at least until all the bases are covered.
4 comentarios
dpb
el 7 de Sept. de 2018
Glad you got something working...the animatedline update to work with alternate functions is worth an enhancement request -- I'll use this thread as background motivation to submit it.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!