Building an Example Model

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.

The Original Simulink Model

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.

Replacing Simulink Blocks with Gauges

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.

Building the Model

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.

  1. Open the Simulink Library Browser and create a new model window. For details on how to do this, see Start the Simulink Software.

  2. From the Angular Gauges library, drag the Lower Right block into the model.

  3. From the Simulink Sources library, drag the Sine Wave block into the model window.

  4. Double-click the Sine Wave block and set the block's parameters as follows:

    • Sine typeTime based

    • Time (t)Use simulation time

    • Amplitude10

    • Bias12.5

    • Frequency (rad/sec)0.1

    • Phase (rad)0

    • Sample time0.1

    • Interpret vector parameters as 1–Don

  5. From the Simulink Math Operations library, drag the Gain block into the model window.

  6. Double-click the Gain block and change the Gain parameter to 4.

  7. Draw connection lines from the Sine Wave block to the Gain block, and from the Gain block to the Lower Right block.

  8. From the model window's Simulation menu, choose Model Configuration Parameters.

  9. 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.

Running the Simulation

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.

Saving the Model

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.

Printing the Model

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.

    Note:   Note that the printing functionality in Simulink software does not print the active areas of Gauges Blockset blocks. Instead, it shows only the outline of those blocks.

Was this topic helpful?