MATLAB: Does the example code in the documentation page “Create Toolbars for Programmatic Apps” not work correctly

'matlab.ui.figure'.classdocforMATLABtoolbar

I am following the example codes in "Create Toolbars for Programmatic Apps" doc page. However, I am getting the following error : 
No appropriate method, property, or field 'Toolbar' for class
'matlab.ui.Figure'.
Why is this?

Best Answer

The lines 
fh.Toolbar = 'figure'; % Display the standard toolbar

fh.Toolbar = 'none'; % Hide the standard toolbar

should be changed to 
fh.ToolBar = 'figure'; % Display the standard toolbar
fh.ToolBar = 'none'; % Hide the standard toolbar
This is a typo in the documentation page. The documentation team is aware of this.