Opening a workspace plot stored in a variable. How?
19 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
rbarata
il 23 Nov 2015
Commentato: Walter Roberson
il 26 Nov 2015
Hello, my friends
Given the code bellow:
>> x = -pi:pi/20:pi;
>> y = sin(x);
>> f = figure;
>> p = plot(x,y);
>> txt1 = text(0.2,0,'sin(x)');
>> p.Color='r'; %close the plot after this change.
>> p.Color='g';
Invalid or deleted object.
I wanted to change the plot line from red to green but, first of all, I noticed I can't do it without the plot being open. Hence the error at the end. Is this right?
Next, this code (hence the variables too) is not saved in any file so how do I open the plot again? It's stored as a variable p not saved any where.
Thanks
0 Commenti
Risposta accettata
Walter Roberson
il 23 Nov 2015
See print() and saveas() and hgsave()
Closing a plot deletes it. If you just want to make it invisible without deleting it, you set its Visible property to 'off'
8 Commenti
Walter Roberson
il 26 Nov 2015
y = sin(x) creates a numeric variable, not a plot. The numeric variable will continue to exist as long as there is a reference to it; typically the variable will disappear as when the function returns.
plot() is for creating line graphics. The graphics can be made invisible, but closing the figure deletes the graphics unless they are saved somewhere.
When you close a figure by using your operating system window manager to click on the 'X', you are running close() which you should read the documentation for, including following through to http://www.mathworks.com/help/matlab/ref/figure-properties.html#prop_CloseRequestFcn
"The closereq function unconditionally deletes the current figure, destroying the window"
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Line Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!