Main Content

Design Custom Image Displays Based on Signal Value Ranges

R2026b

This example shows how to display an image that depends on the value of a signal during simulation. The model in this example uses the MultiStateImage block to represent different stages of a battery-charging process by displaying different images as the input signal moves through specified ranges.

Examine the CustomMultiStateImage model.

open_system("CustomMultiStateImage.slx");

Finished and simulated Simulink model from example.

To create a display like the one in the example model, add a customizable MultiStateImage block to your model. Double-click the model canvas and begin typing MultiStateImage. Select the search result with the library path Simulink/Dashboard/Customizable Blocks.

To use the MultiStateImage block, you define a set of states with corresponding images. Configure the block to specify each state as a range of input values.

  1. In the model canvas, select the MultiStateImage block.

  2. In the Simulink® Toolstrip, on the Modeling tab, in the Design gallery, select Property Inspector.

  3. On Property Inspector, on the Parameters tab, select the Specify State Values as Ranges check box.

In the example model, the state ranges are defined as shown in this image.

MultiStateImage block in design mode with the Parameter tab of the Property Inspector open

To add images and specify the range of values for each image:

  1. Double-click the thumbnail icon under Image in the row with [undefined] value ranges.

  2. Navigate to the location of the image you want and select it. In this example, the images are in the CustomMultiStateImage folder, and the first defined state is associated with the Battery_0.png file.

  3. Double-click the thumbnail icon in the second row and select an image for the second define state. In this example, the image is Battery_20.png.

  4. Click to add five additional state rows.

  5. Double-click the thumbnail icon in each additional state row, and select the remaining battery images.

  6. Enter the minimum and maximum input values for each image in the Min and Max columns.

MultiStateImage block with defined state values and battery display images.

In the model, a Sine Wave block connected to an Abs block generates a signal that represents the battery status. Connect the MultiStateImage block to the Sine Wave Absolute Value signal.

  1. Select the MultiStateImage block.

  2. Click the Connect button that appears above the block.

  3. Select the Sine Wave Absolute Value signal output.

  4. Select the Sine Wave Absolute Value option in the table that appears.

  5. Click the X in the upper right corner of the Simulink window to exit connect mode.

The signal line named Sine Wave Absolute Value is selected in the model diagram. A table is displayed below the selected signal. In the table, the signal named Sine Wave Absolute Value is selected.

To see the MultiStateImage block display the battery images based on the value of the connected signal, simulate the model. The model uses simulation pacing to slow model execution to display the different battery states. For more information about simulation pacing, see Simulation Pacing Options.

See Also

Blocks

Topics