Why does my patch appear on the incorrect figure when using the DRAWNOW and QUESTDLG functions in MATLAB 6.5 (R13) ?

1 view (last 30 days)
When I execute the following commands:
axis([-1,1,-1,1,-1,1]);
patch([-1;1;1;-1],[-1;-1;1;1],[-.5;-.5;-.5;-.5],[0,1,0]);
if ~isequal(questdlg('OK to proceed with plot?'),'Yes')
return
end
figure;
axis([-1,1,-1,1,-1,1]);
drawnow
patch([-1;1;1;-1],[-1;-1;1;1],[.5;.5;.5;.5],[1,0,0]);
The second patch gets printed on the first figure, when I am expecting the second patch to get printed on the second figure.
However, if the QUESTDLG function is removed the second patch gets printed on the correct (i.e. the second) figure.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
There is a bug in MATLAB 6.5 (R13) while using the QUESTDLG function with the PATCH function. This behavior occurs when:
1. The QUESTDLG function is used with the PATCH function.
2. The PATCH function is printing the patches to more than one figure.
3. The DRAWNOW function is used immediately after specifying the second figure.
To workaround this issue, explicitly tell the second patch to display on the second figure by setting the patch's 'Parent' property to the handle of the second axes. Your code might look like this:
figure(1);
ha1 = axes;
axis([-1,1,-1,1,-1,1]);
patch([-1;1;1;-1],[-1;-1;1;1],[-.5;-.5;-.5;-.5],[0,1,0]);
if ~isequal(questdlg('OK to proceed with plot?'),'Yes')
return
end
figure(2);
ha2 = axes;
axis([-1,1,-1,1,-1,1]);
drawnow;
patch([-1;1;1;-1],[-1;-1;1;1],[.5;.5;.5;.5],[1,0,0],'Parent',ha2);

More Answers (0)

Categories

Find more on Dialog Boxes 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!