MATLAB: How to create a toolbar in a GUI created using GUIDE in MATLAB

createfigureguideMATLABtoolbar

I have created a GUI using GUIDE. When I run the program, I do not see the toolbar in the activated figure. I would like to have the figure toolbar displayed by default. The menubar for the activated figure can be made visible or invisible by default with the help of the property MenuBar. I am not able to find a property for the Toolbar.

Best Answer

This enhancement has been incorporated in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
There is an undocumented property called 'Toolbar' for the figure that can be set to 'figure' so the toolbar will be displayed by default. Refer the following steps to achieve this:
1. Right-click in the GUIDE figure. (Click in the gray area with the grid lines. Do not right-click on any uicontrols.)
2. Select View Callbacks -> CreateFcn
3. This will create a new callback function in your corresponding GUI program file.
4. In this function include the following code:
set(hObject,'toolbar','figure');
where h refers to the figure handle. In version 6.1 and earlier, the default is h; after 6.1 it is hObject.
5. Save your changes and run your code. You will see the toolbar in the figure.