How can I plot data in a existing figure?

19 Ansichten (letzte 30 Tage)
Mark
Mark am 12 Jul. 2013
Hi All,
I am trying to add some data to an existing figure that I load in my script. A simplified example:
Test = open('Test.fig');
figure(Test)
hold on
A = 1:1:100
B = 0:0.02:1.98
plot(A,B)
However, this doesn't give the expected results as it overwrites the opened figure. Removing the 'hold on' makes the opened figure remain active but the line is not added and is nowhere to be found. I have been playing with hgload and copyobj as well but I didn't get it to work.
Any suggestions?
Thanks, Mark
  8 Kommentare
Thomas
Thomas am 12 Jul. 2013
Bearbeitet: Thomas am 12 Jul. 2013
I dont think you understand.. its not overwriting.. its covering it with the new plot( since you are plotting the same identical thing) If you plot something else it will show two different line on the same figure as
Test = open('Test.fig');
figure(Test)
pause(2) %pause for you to see that it is bringing ur fig up
hold on
A = 1:1:100
B = 0:0.01:0.99
plot(A,B,'*','color','r')
Mark
Mark am 12 Jul. 2013
Thanks, I think I get what you are saying but how can I solve this issue? As I mentioned I basically want to paste some extra lines into an existing figure (with totally different lines).

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 13 Jul. 2013
I'm not sure what comes back when you save a figure as a .fig format file and then recall it. I'd save the data into a .mat file instead and then re-create your figure, after reading in the mat file, by plotting all the old data and annotations, then adding your new stuff.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by