This section illustrates how to build and use a simple system, first using Simulink® blocks alone, and then using a Gauges Blockset™ block. By building the latter model, you can practice finding and using a Gauges Blockset block. By comparing the two models, you can get a better sense of how graphical icons might enhance the look, feel, and usability of your own models.
|On this page…|
Consider a system in which a Sine Wave block feeds into a Gain block, while a Scope block displays the output from the Gain block. These blocks are in the Simulink library.
If you simulate this system and double-click the Scope block, then the Scope traces the value of its input signal over time.
You can replace the Scope block from the Simulink library with a realistic-looking display. For example, a Lower Right block can display the sine wave value at each instant during the simulation.
To build the model described earlier, follow the steps below. Alternatively, enter gauges_simple in the MATLAB® Command Window to open a completed copy of the model.
Open the Simulink Library Browser and create a new model window. For details on how to do this, see Start the Simulink Software.
From the Angular Gauges library, drag the Lower Right block into the model.
From the Simulink Sources library, drag the Sine Wave block into the model window.
Double-click the Sine Wave block and set the block's parameters as follows:
Sine type — Time based
Time (t) — Use simulation time
Amplitude — 10
Bias — 12.5
Frequency (rad/sec) — 0.1
Phase (rad) — 0
Sample time — 0.1
Interpret vector parameters as 1–D — on
From the Simulink Math Operations library, drag the Gain block into the model window.
Double-click the Gain block and change the Gain parameter to 4.
Draw connection lines from the Sine Wave block to the Gain block, and from the Gain block to the Lower Right block.
From the model window's Simulation menu, choose Model Configuration Parameters.
In the Simulation time section of the Solver pane, set the Stop time parameter to Inf. In the Solver options section of the Solver pane, use the Solver menu to select discrete (no continuous states) since this model does not have continuous states.
Now you can run the model and watch how the sine wave affects the needle on the Lower Right block.
Run the simulation by choosing Run from the model window's Simulation menu. While the simulation is running, you can observe results on the Lower Right block. This figure shows the model after the needle of the Lower Right block is displaced from its default position.
To stop the simulation, choose Stop from the model window's Simulation menu.
Save the model by choosing Save from the model window's File menu. When you save a model that contains blocks from the Gauges Blockset library, the file automatically reflects the current state of the control that is embedded in the block.
You can print the structure of the model by choosing Print from the model window's File menu. Or you can capture the same image in a .bmp file and print the file by entering either of the following commands in the MATLAB Command Window.
print -smodelname -dbitmap filename print(['-s','modelname'],'-dbitmap','filename')
Here, modelname and filename list the names of the Simulink model and the bitmap file, respectively. For example, if the open model is called sample, then this command saves it in a file called samplepic.bmp.
print -ssample -dbitmap samplepic
After the application creates the bitmap file, you can insert it into an application that can print it.