How to animate line on polar axes plots

14 visualizzazioni (ultimi 30 giorni)
Mark Duarte
Mark Duarte il 5 Set 2018
Commentato: dpb il 7 Set 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.

Risposta accettata

dpb
dpb il 5 Set 2018
Modificato: dpb il 6 Set 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 Commenti
Mark Duarte
Mark Duarte il 6 Set 2018
Ugh yes thank you!!! That did the trick. Movie making time.
dpb
dpb il 7 Set 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Just for fun in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by