Control camera toolbar programmatically
cameratoolbar displays a camera toolbar in the current figure
that enables interactive manipulation of the axes camera and light. If there is no figure
available, then MATLAB® calls the
figure function to create one.
cameratoolbar( displays a camera
toolbar with the visibility option specified.
visibility of the camera toolbar in the current figure (1 if visible, 0 if not
tf = cameratoolbar('GetVisible')
cameratoolbar( resets the current
camera, scene light, or target to the state before interactions began.
current camera motion control mode.
m = cameratoolbar('GetMode')
the principal axis of camera motion.
current principal axis of camera motion.
p = cameratoolbar('GetCoordSys')
Display Camera Toolbar in Figure
Create a figure and add a camera toolbar to the figure. Note that you can also display the camera toolbar by selecting Camera Toolbar from the figure window's View menu. The camera toolbar appears below the default figure toolbar.
f = figure; tb = cameratoolbar(f);
Set the camera toolbar mode to zoom by using
state — Toolbar visibility state
Toolbar visibility state, specified as one of these values:
'show'— Show the camera toolbar.
'hide'— Hide the camera toolbar.
'toggle'— Toggle the camera toolbar visibility between the
'close'— Remove the camera toolbar from the figure.
reset — Reset option
Reset option to the default state, specified as one of these values:
'ResetCameraAndSceneLight'— Reset the current camera and scene light.
'ResetCamera'— Reset the current camera.
'ResetSceneLight'— Reset the current scene light.
'ResetTarget'— Reset the current target.
'NoReset'— Do not set the state of any camera controls. This option is valid only for figures created with the
Alternatively, you can reset the camera and scene light using the toolbar, by clicking the corresponding button.
mode — Camera motion control mode
Camera motion control mode, specified as one of these values:
'orbit'— Orbit camera.
'orbitscenelight'— Orbit scene light.
'pan'— Pan or tilt camera.
'dollyhv'— Move camera horizontally or vertically.
'dollyfb'— Move camera forward or back.
'zoom'— Zoom camera.
'roll'— Roll camera.
'nomode'— No camera mode.
For more information about the various modes, see Camera Toolbar.
Alternatively, you can set the camera mode using the toolbar, by clicking the corresponding button.
coordsys — Principal axis of camera motion
Principal axis of camera motion, specified as one of these values:
'x'— Principal axis
'y'— Principal axis
'z'— Principal axis
'none'— No principal axis.
For for more information about the principal axes, see Camera Toolbar.
Alternatively, you can set the principal axis using the toolbar, by clicking the corresponding button.
parent — Parent figure
Parent figure, specified as a
tf — Camera toolbar visibility
Camera toolbar visibility, returned as a logical value. If the camera toolbar is
tf is logical
tf is logical
m — Camera motion control mode
Camera motion control mode, returned as a character vector. See the
mode input argument for the list of possible values.
p — Principal axis of camera motion
Principal axis of camera motion, returned as a character vector. See the
coordsys input argument for the list of possible values.
tb — Camera toolbar
Camera toolbar, returned as a
Version HistoryIntroduced before R2006a
R2022b: Visual toolbar support for figures created with the
Syntaxes that make the visual toolbar interface visible are now supported by figures
created with the
uifigure function. Previously, figures created with
uifigure function supported only syntaxes that did not directly
make the toolbar visible. Now, the visual camera toolbar interface and all syntaxes are
supported by figures and UI figures.
R2022a: Syntax support for figures created with the
Syntaxes that do not directly make the visual camera toolbar interface visible are now
supported by figures created with the
uifigure function. Previously,
only figures created with the
figure function supported controlling the
camera toolbar programmatically.