Reputation: 680
I wrote a matlab function that does a lot of things on a figure.
Now, the problem is the figure is NOT displayed until the program terminates its execution, but I would want the figure to be displayed, in realtime, with all modifications, and always in the foreground, while the program progresses.
How I can do this? figure('visible','on')
does not sort any effect, nor set() command.
Code snippet:
set(gcf,'visible','on')
parfor (i=1:n, 8)
if norm(A(i,:))<1
countr=countr+1;
end
hold on;
plot(A(i,1),A(i,2),'+')
end
Thanks.
Upvotes: 2
Views: 822
Reputation: 10676
The statement figure('visible','on')
creates a new figure, but you want to make the already existing one visible, thus use:
set(gcf,'visible','on')
EDIT 2
I cannot reproduce the issue (probably the example is not a good one):
A = rand(100,2);
set(gcf,'visible','on')
hold on
parfor (i=1:100, 8)
plot(A(i,1),A(i,2),'+')
pause(0.01)
end
OLD EDIT Parfor and graphics (source "How to see plots during parfor"):
According to the source, the quick answer is you cannot update the screen output within the parfor
but with the drawnow
which defies the purpose of the parfor. Therefore, do you strictly need the parfor?
However, see my EDIT 2.
Upvotes: 0
Reputation: 3193
I would not recommend it, but I think you need to add some drawnow
statements, it will sync the visual and calculation thread.
Upvotes: 1
Reputation: 5126
By default, the figure must be visible; otherwise you should modify this property. Thus, try to look for any code that includes wait
.
Other option is to try figure(gcf)
to bring the focus to the figure you want.
Upvotes: 0