×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

very SIMPLE question about a FIGURE

very SIMPLE question about a FIGURE

very SIMPLE question about a FIGURE

(OP)
hi all
okay, i have a simple plot saved in a .fig file
i JUST need to RETRIEVE the data of the Y axis
i m SURE it can be done, but i cant figure it out
i have even SEEN the data when editing the plot but i cant save it to workspace
help?

RE: very SIMPLE question about a FIGURE


 were are the original data? I mean, you ploted that from one Variable from workspace, right?. that variable exist?

  

RE: very SIMPLE question about a FIGURE

well, maybe the workspace was deleted, unsaved or so on, so the only proof for data is the figure..

sorry: real interesting, but I can't help you..

good luck!

RE: very SIMPLE question about a FIGURE

(OP)
hi
yes, the original data was deleted, now i just have the .fig file left

i m really buggered, cuz i CAN see the data, i just need to "edit" the plot, then click on Y axis, and the data is THERE!! (check it out), but theres no option to "save it to workspace", as can be done with the "basic fitting" (mean, std, variance...)

if i have no other choice, i can RETYPE the data by hand (i insist, its there), though is just CANT believe there is no other way to retrieve it!!

i tried to edit the .fig file but its a load of cr*p

anyone help?

P.D. if anyone sorts this out, this ought to go to the HALL OF FAME, truely...

RE: very SIMPLE question about a FIGURE

(OP)
ok, me again
its 3 am, and im listening to limp bizkit to keep my mind sharp

i think i got a "partial" solution, nuff for me today, ill try to find something better tomorrow

ok, so i just have the fig

>> open crappy.fig
>> gcf       % returns the handle of the current figure
>> saveas(gcf, 'crappy', mmat) % that should create a crappy.fig and a crappy.m, ignore any warning msg

>> edit crappy.m
% scroll down and u will find something like 'YData',[2 11 7 14]);' (this is just a stupid example, i used durer magic matrix

well, at least now i only have to "cut & paste" if the number is low

if its a big number (hundreds ++) it will also create a file called crappy.mat, its a cell array
just type

>> load crappy

and it will get to ur workspace as a "mat" variable
mat{i} is the ith-dimension

well, im going to get some deserved sleep...

RE: very SIMPLE question about a FIGURE

Its possible to extract the data from a figure. In Matlab R12 onwards (atleast) a figure is actually an active object. The figure oject can contain a number of "children". Also objects (line, legend, text, buttons, etc.). Each one of these children have their own properties and their own children. The data you plotted is contained within a "line" object. To access this you must do something like this.

Open myfig.gif
myfigId=gcf;
myfigChildren=get(myfigID, 'Children');
%returns all the children in an array

%now you must identify which one of these children is the line you are interested in. To do this type

get(myfigChildren(1));
get(myfigChilfren(2));

%... etc untill you see some data in the Xdata Ydata properties. Then..

%lets say that the line you want is object 2 in the figure
%so now

myline=get(myfigChildren(2));
myxdata=get(myline,'Xdata');
myydata=get(myline,'Ydata');

%and voila, Hope this helps

JR.



RE: very SIMPLE question about a FIGURE

(OP)
thanx a lot
i had been looking through the set and get functions, but hadnt quite grasped how to use em

RE: very SIMPLE question about a FIGURE

i had the same problem with extracting data from a .fig file, and came across a solution at:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=U...

excerpt from the above URL:
----start excerpt-----
openfig('MyTestFig.fig');
HandlesOfLines=findobj(gcf,'type','line');
% This reopens the figure and finds the Line object inside it

XData = get(HandlesOfLines,'Xdata')
YData = get(HandlesOfLines,'Ydata')
% This retrieves the X and Y data, which are:

XData =
     1     2     3     4     5     6     7     8     9    10
YData =
    10     9     8     7     6     5     4     3     2     1

As you can see, these are the inputs we passed to the PLOT command.

You may have some issues with finding the right line from which to retrieve the X and Y data if you have multiple lines in the figure ... but hopefully they have some other distinguishing characteristic that you can use with the
FINDOBJ command.

--
Steve Lord
slord@mathworks.com
----end excerpt-----

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources