MATLAB: Does the MENU method place dynamic buttons in a different window in MATLAB R2013b

buttonfigureMATLABmenuparentwindowwrong

I am using the MENU method and passing static and dynamic inputs to it. I also have another figure window that plots some data every x seconds as shown in the code below. I noticed that sometimes the MENU buttons are placed in the other figure window. Why does this happen?
function foo()
f = figure;
NumberFrameDisplayPerSecond = 10;
tmr = timer('TimerFcn', {@timerFcn, f},'Period',1/NumberFrameDisplayPerSecond,'ExecutionMode','fixedRate','BusyMode','drop');
start(tmr)
tic
stopMenu = false;
while ~stopMenu
t = sprintf('%s',toc);
choice = menu('stuff','stop',t);
switch choice
case 1
stopMenu = true;
otherwise
end
end
stop(tmr)
delete(tmr)
function timerFcn(src, evt, f)
figure(f)
plot(rand(10,1));

Best Answer

  • This is a bug with the MENU method where the parent figure is not being set while creating the objects that go on the MENU. 
    To work around this issue, use the attached MYMENU method.