Dials & Gauges Blockset    

Placing ActiveX Controls in a Figure Window

In this example, a simple model displays the simulation time on an ActiveX Control block located in a figure window. You can open a completed copy of the model by typing dng_offblock in MATLAB, or you can follow the instructions below for building it yourself. The completed model looks like this.

  1. Create and execute an M-file called dng_gaugewindow that consists of these statements.
  1. This M-file creates a figure window containing a Generic Angular Gauge, whose program ID is mwagauge.agaugectrl.1. The M-file also specifies the position of the ActiveX control in the figure window. For more information about actxcontrol, see its reference documentation.

  1. Create an M-file called dng_off_block that consists of these statements.
  1. The dng_off_block function returns the handle of the ActiveX Control block that is to be connected to the ActiveX Control block.

  1. Open the ActiveX Control block to modify its parameters. First, clear the In-block control check box. When you clear the In-block control check box, the number of fields on the dialog box changes.
  2. In the Connections field, select input to delete the outport on the ActiveX Control block.
  3. In the Input property field, enter NeedleValue. When a signal is received at the ActiveX Control block's inport, this property of the ActiveX Control block referenced by the ActiveX Control block (the Generic Angular Gauge) is set with the signal value.

  1. In the Handle location field, enter dng_off_block. With the fields filled in, the Block Parameters dialog box looks like this.

  2. Click on OK. MATLAB executes the dng_off_block M-file, which returns the handle of the ActiveX Control block in the figure window. The figure window looks like this (resized).

  3. Run the simulation. Notice that the clock time is passed to the Generic Angular Gauge.

Saving and Reopening the Model

If you want to use this model in a different MATLAB session, then you must preserve both the model and the MATLAB commands that create the figure window and gauge. Here is an easy way to do this:

  1. Save the model to give it a name.
  2. If the model's name is mymodel, then use these commands in MATLAB to preserve the commands that create the figure window and gauge.

Now, whenever you open mymodel, MATLAB automatically creates the figure that contains the gauge.


  Associating Top-Level Blocks with the Subsystem Block Reference