place Figure handles in vektor
7 views (last 30 days)
Show older comments
Hello im making a funtion were its possible to typ in a fnction and make a plot of it,
function plot_handles=skapaplot(varargin)
syms x X;
global plot_handles;
persistent n;
if isempty(n)
n = 1;
else
n = n + 1;
end
funk=input('function:','s');
figure;
ezplot(funk);
plot_hanldes(n)=gcf;
end
I want to keep track of how many figure and other information about the line in the plot, in the vector plot_handles. how can i do it in a easy way?
6 Comments
Accepted Answer
Jan
on 23 May 2011
A cleaned version of your function, which avoid using global variables:
function Reply = skapaplot(Command)
persistent plot_handles
if nargin > 0 && strcmpi(Command, 'gethandles')
Reply = plot_handles;
return;
end
syms x X;
funk = input('function:', 's');
FigH = figure;
plot_handles = cat(2, plot_handles, FigH);
ezplot(funk);
Now the function replies the list of handles, if it is called with the input 'gethandles'.
More Answers (0)
See Also
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!