How to animate line on polar axes plots
14 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
dpb
2018-9-5
编辑:dpb
2018-9-6
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 个评论
dpb
2018-9-7
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.
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!