Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
re-open a figure to continue processing

Subject: re-open a figure to continue processing

From: Konst

Date: 20 Oct, 2010 11:47:04

Message: 1 of 4

I have a square wave and I use ginput to select each time 2 points in a for-loop which breaks when I select points that aren't on the curve.When I finish, I save it as a .fig file.How can I reopen the last figure to process it again(let's say I want to add a few more points using ginput) without having to run the whole algorithm from the beginning?

i=1;
while i>=1;
    [x,y] = ginput(2);
get(gco,'Type');
TF=strcmp(get(gco,'Type'),'line');
if TF==0
    saveas (gcf,'lastgraph.fig');
    break;
end
d(i)=x(2)-x(1)
i=i+1
end

Subject: re-open a figure to continue processing

From: Konst

Date: 21 Oct, 2010 18:11:04

Message: 2 of 4

"Konst " <konstance1@hotmail.com> wrote in message <i9mkro$oib$1@fred.mathworks.com>...
> I have a square wave and I use ginput to select each time 2 points in a for-loop which breaks when I select points that aren't on the curve.When I finish, I save it as a .fig file.How can I reopen the last figure to process it again(let's say I want to add a few more points using ginput) without having to run the whole algorithm from the beginning?
>
> i=1;
> while i>=1;
> [x,y] = ginput(2);
> get(gco,'Type');
> TF=strcmp(get(gco,'Type'),'line');
> if TF==0
> saveas (gcf,'lastgraph.fig');
> break;
> end
> d(i)=x(2)-x(1)
> i=i+1
> end

anyone??

Subject: re-open a figure to continue processing

From: Konst

Date: 22 Oct, 2010 12:50:05

Message: 3 of 4

This is what I've done so far
openfig('figure.fig','new')
x=get(gco,'xdata') %but it returns an empty vector
Then I tried
x=get(get(gca,'Children'),'Position')
for some rectangles tha I have on the figure but it also returns an empty vector. Have I done sth wrong?
Then I thought sth really time-consuming: Create a new algorithm which opens the figure and then rewrite all the commands tha I had in the first algorithm so basically it does the same thing but It has as input the figure.But how do I combine my new results with the first ones and not just overwright them?

Subject: re-open a figure to continue processing

From: Steven_Lord

Date: 22 Oct, 2010 13:51:33

Message: 4 of 4



"Konst " <konstance1@hotmail.com> wrote in message
news:i9s19t$l4m$1@fred.mathworks.com...
> This is what I've done so far
> openfig('figure.fig','new')
> x=get(gco,'xdata') %but it returns an empty vector

Yes, because what guarantee do you have that GCO is the line whose data you
want to retrieve?

> Then I tried
> x=get(get(gca,'Children'),'Position')
> for some rectangles tha I have on the figure but it also returns an empty
> vector. Have I done sth wrong?

That would indicate that GCA has no children.

Use FINDOBJ or FINDALL to obtain the handles of the appropriate objects (of
Type 'line' or 'lineseries', most likely) in your figure and then retrieve
their XData, YData, etc. properties.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us