Extract data from polar plot [example.fig]
18 次查看(过去 30 天)
显示 更早的评论
I recieved a series of polar plots [Example_n.fig, with n = (1000:1:1250)] for 36 headings. Now, I would like to extract the data of these plots to matrices, so i can import the data in excel.
So I used the following code, which does open the figure and work for simple x,y - plots, but doesn't extract the data from the polar plots.
open 'Example_n.fig'
D=get(gca,'Children');
XData=get(D,'XData');
YData=get(D,'YData');
Data=[XData' YData'];
Thanks in advance!
0 个评论
回答(3 个)
dpb
2018-11-28
编辑:dpb
2018-11-28
Well, a variant of that works ok here with the example polar plot in the documentation.
>> hF=openfig('polar.fig');
>> hAx=gca;
>> hL=findobj(hAx,'Type','Line');
>> XY=[hL.XData.' hL.YData.'];
>> whos XY
Name Size Bytes Class Attributes
XY 629x2 10064 double
>>
The problem you're having is that probably the plot was created with the new(ish) polarplot function rather than with polar. With it the data properties are RData and ThetaData instead of X/YData.
Everything above still works except use
RTh=[hL.RData.' hL.ThetaData.'];
after finding the line handle.
5 个评论
dpb
2018-11-29
编辑:dpb
2018-11-29
What release are you using? The new polarplot wasn't introduced until R2016x, but a test here w/ R2014b failed to be able to load a figure created with it as expected.
The error message about RData is the expected one if the plot was created by the venerable polar plot routine; the line object created by it doesn't include the polar coordinate properties.
The symptom with X/YData I can't seem to reproduce by any machination with either release or particular plotting function, however. With the polarplot object, XData/YData are empty here with R2016b/R2017b but that plot type can't be created w/ R2014b at least by openfig trying to read a .fig file created by the later releases I have.
Maybe one of the R20YY releases has a bug I can't recreate???
dpb
2018-11-29
How about attaching one of the files that cause you the problem -- then folks here can see if have similar symptoms or isolate something unique to your particular system.
Also, if you can, see if the creator of the .fig files can tell you which release was used to create them as well as the release you're using. Oh--and OS on which running each would possibly be of interest/significance.
Hannes Morgenroth
2022-3-29
Had the same issue and for me the solution was as simple as using 'RData' and 'ThetaData' instead of 'XData'and 'YData'.
%find the handle
ax=gca;
h = findobj(ax,'Type','Line');
%get the data (dot notation instead of get() for readability)
r=h.RData;
theta=h.ThetaData;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Polar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!