Extract time series data from figure

I have certain data only as .fig files but I want to extract the time series (x- and y points) of a particular graph and have them as a normal variable in my workspace for further analysis.
A first step that might be helpful is to open the fig file as a .mat file with load('Example.fig','-mat') The .fig file (see my dropbox link below) contains 4 figures, I am only interested in the upper part of figure 2 (see arrow http://i27.lulzimg.com/92f4285ead.png ). So I suppose the XDATA and YDATA of figure 2 should be somewhere in the second struct file under children --> .... I cannot find it within this complicated structure, and the variable editor doesn't seem to offer a search function. Can you find it?

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 9월 29일

0 개 추천

Use this example:
f=figure(1);
h=plot(magic(4));
l=findobj(gca,'type','line');
x1=get(l(1),'xdata')
y1=get(l(1),'ydata')
x2=get(l(2),'xdata')
y2=get(l(2),'ydata')

댓글 수: 3

Felix
Felix 2011년 9월 29일
Thanks. But when I try this with figure 2 (which contains two graphs) of my example file, for some reason findobj only finds the lines of the lower graph not of the upper graph.
I will play with it some more, this seems to be what I am looking for.
Felix
Felix 2011년 9월 29일
So, within the figure window when I go under properties editor and select the line that I want it shows me it's name under "Display Name: ..."
How can I access this object with findobj when I know the display name?
Fangjun Jiang
Fangjun Jiang 2011년 9월 29일
findobj(gca,'type','line','DisplayName',WhateverName).
After running the example code, try get(l(1)) to see all the properties.

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

질문:

2011년 9월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by