lag with "figure" function
Show older comments
I have devised this function in order to make new figures appear where I want them to.
function figuree(varargin)
tic
if ~isempty(varargin)
if varargin{:}>0 && length(varargin{:})<2
figure(varargin{1})
else
error('illegal figuree arguments \n Arguments must be the same as figure')
end
else
toc
figure()
toc
end
set(gcf,'OuterPosition',[1,470,500,558])
This goes perfectly well.
But when I make for example this call:
close all
clear all
figure
figure
figure
figuree(2)
figuree
figuree(2)
figuree
this is my output:
Elapsed time is 0.000186 seconds.
Elapsed time is 0.260609 seconds.
Elapsed time is 0.000017 seconds.
Elapsed time is 3.168427 seconds.
My question is why do I have a sudden 3 second delay ??! (I will also accept advice about how to make new figure appear where I want them to)
Accepted Answer
More Answers (1)
Walter Roberson
on 6 Apr 2011
Have you considered
set(0,'DefaultFigureOuterPosition', [1,470,500,558])
figure() can take a variable length of time because MATLAB processes the event queue each time figure() is called.
3 Comments
j dr
on 11 Apr 2011
Walter Roberson
on 11 Apr 2011
Your apparent 3 second delay might be because you have no toc() for the case where you pass arguments.
By the way, your code for working with varargin is not correct. Test it out by passing multiple arguments...
j dr
on 19 Apr 2011
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!