Search code examples
matlabuser-interfacepositioning

MATLAB How to move a menu to center of screen


I'm trying to get a matlab menu to the center of my screen, so normally i'd write it like this;
choice = menu('choose','1','2');
movegui('choice','center')
But since matlab waits for an input before executing the second line, it doesn't move the gui.
I've seen some workarounds but most of them are really long or ugly.
How do I fix this?

Thanks for the help.


Solution

  • A possibility would be to copy the content of the menu.m file into a new function, rename it and add this line:

    movegui(menuFig,'center');
    

    on line 229. Although I must say that it might be illegal or be against the terms of service...if that's the case I'm not even sure I should propose this. Anyhow by typing edit menu in the command window one can see that the function simply creates a figure (whose handles is menuFig) and adds the number of pushbuttons with appropriate strings corresponding to the number of inputs you provided the function, so in fact that's not that hard to create your own function based on this idea... Good luck!