필터 지우기
필터 지우기

Extract data from polar plot [example.fig]

조회 수: 35 (최근 30일)
Jochem Oostenbroek
Jochem Oostenbroek 2018년 11월 28일
답변: Hannes Morgenroth 2022년 3월 29일
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!

답변 (3개)

dpb
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
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
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.

댓글을 달려면 로그인하십시오.


Jochem Oostenbroek
Jochem Oostenbroek 2018년 11월 29일
Hi DB,
Thanks for the tips. When using your lines, I get the following error
>> RTh=[hL.RData.' hL.ThetaData.'];
No appropriate method, property, or field
'RData' for class
'matlab.graphics.chart.primitive.Line'.
But for using the XData and YData, Matlab returns the error:
"Too many input arguments", which doesn't really make sense to me.
What do you reckon?

Hannes Morgenroth
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;

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by