App Designer provides a tutorial that guides you through the process of creating a simple app containing a plot and a slider. The slider controls the amplitude of the of the plotted function. You can create this app by running the tutorial, or you can follow the tutorial steps listed below.
To run the tutorial in App Designer, click the Open Example button on this page. Alternatively, you can run the tutorial by selecting Open > Interactive Tutorial on the Designer tab in the App Designer toolstrip.
Start App Designer by typing
the MATLAB® command line. Then perform the following steps.
Drag an Axes (2D) component from the Component Library onto the canvas.
Drag a Slider component from the Component Library onto the canvas. Place it below the axes, as in the preceding image.
Replace the slider label text. Double-click the label
and replace the word
Above the canvas, click Code View to edit the code. (Notice that you can switch back to edit your layout by clicking Design View.)
In the code view, add a callback function that executes MATLAB commands
whenever the user moves the slider. Right-click
the Component Browser. Then select Callbacks > Add ValueChangedFcn
callback in the context menu. App Designer
creates a callback function and places the cursor in the body of that
in the axes. Add this command to the second line of the
plotcommand specifies the target axes (
app.UIAxes) as the first argument. The target axes is always required when you call the
plotcommand in App Designer.
Change the limits of the y-axis
by setting the
YLim property of the
Add this command to the third line of the
app.UIAxes.YLim = [-1000 1000];
YLimproperty. Always use the pattern
Propertyto access property values.
Click Run to save and run the app.