Main Content

Visualize and Edit N-Dimensional Data Using Mask Lookup Table Control

You can visualize and edit N-dimensional lookup table data in mask dialog using the lookup table control. Look up tables approximate the functions and significantly reduce the computation time using simple lookup operations.

Visualize and Edit Table and Breakpoint Data Using the Lookup Table Control

Consider a scenario where the fuel flow is determined by the torque and engine Speed. To specify the data explicitly for table data and breakpoint parameters:

1. Right-click on the block, click Edit Mask to open the Mask Editor. In the Mask Editor go to Parameters & Dialog pane, create edit parameters Torque and Engine Speed for breakpoints. In the Property editor pane, enter the values for the breakpoints in the Values box.

2. Create an Edit parameter Fuel Flow for table data in the Property editor pane, enter the values in the Value box.

3. Add a lookup table control. Enter the table properties Table Parameter, Table Unit, Table Display Name, Breakpoint Parameters, Breakpoint Units, and Breakpoints Display Name. Click OK.

4. Double-click the masked block to view the lookup table. Click on a cell to edit the value.

To view the heat map of the table, right-click on a cell, then click Heatmap On.

Reference Promoted Parameters for Table and Breakpoint Data

You can follow the same steps to reference promoted parameters to build a lookup table.

Specify Table Data and Breakpoint Data Using Lookup Table Object

To reference an object in the Lookup Table Control:

1. Create an object named lutobject in the model or base workspace with table and breakpoint data.

2. Create an Edit parameter and enter the Value as lutobject created in the model workspace.

3. Create the lookup table control, lutcontrol and reference the Edit parameter.

4. The lookup table is now populated with the table and breakpoints data.

Switch Between Explicit Data Specification Mode and Data Referencing Mode

You can switch between Explicit data specification mode and Data referencing mode using a Popup parameter. Create a Popup parameter and use it in the lookup table control to choose between explicit data specification mode and object referencing mode.

Use callback code for the Popup parameter.

dataspec_paramName = 'dataspec';
  bp1_paramName = 'torque';
  bp2_paramName = 'enginespeed';
  tbl_paramName = 'fuelflow';
  lutobj_paramName = 'lutobject';
  underlyingLUTblock = 'slexMaskLookupTableControlExample/LUT Control with Data Specification Mode/2-D Lookup Table';
  dataSpec = get_param(gcb, dataspec_paramName);
  maskObj = Simulink.Mask.get(gcb);
  lutoParam = maskObj.getParameter(lutobj_paramName);
  bp1Param = maskObj.getParameter(bp1_paramName);
  bp2Param = maskObj.getParameter(bp2_paramName);
  tableParam = maskObj.getParameter(tbl_paramName);
  set_param(underlyingLUTblock, 'DataSpecification', dataSpec);
  if strcmp(dataSpec, 'Lookup table object')
      bp1Param.Visible = 'off';
      bp2Param.Visible = 'off';
      tableParam.Visible = 'off';
      lutoParam.Visible = 'on';
      bp1Param.Visible = 'on';
      bp2Param.Visible = 'on';
      tableParam.Visible = 'on';
      lutoParam.Visible = 'off';

Share Explicit Breakpoint Data Between Lookup Tables

Many applications use the same breakpoints for different kinds of data. You can create multiple lookup tables by sharing breakpoint data. For example, Exhaust Temperature, Air Pressure, and Fuel Flow use the same breakpoints Torque and Engine Speed. Create multiple containers in the Mask Editor for each lookup table and use the same breakpoints in each table.

Visualize Multidimensional Data

To visualize multidimensional data, create Edit parameters for table and breakpoints and enter the values. To visualize the data for a dimension, select the parameter for that dimension from the list.

Add Lookup Table Control Programmatically

To add a mask lookup table control programmatically:

1. Get the mask object.

maskObj = Simulink.Mask.get(blkhndl);

2. Add table data and breakpoint parameters to the mask.

maskObj.addParameter('Name', 'torque', 'Prompt , 'Torque:', 'Type',  'edit');
maskObj.addParameter('Name', 'speed', 'Prompt', 'Engine speed:', 'Type',  'edit');
maskObj.addParameter('Name', 'fuelflowtable', 'Prompt', 'Fuel Flow Map:', 'Type',  'edit');

3. Set the table properties.

lutControl.Table.Name = 'fuelflowtable';
lutControl.Table.Unit = 'kg/s ;
lutControl.Table.FieldName = 'Fuel Flow';

Set breakpoint properties of Dimension 1.

lutControl.Breakpoints(1).Name = 'torque';
lutControl.Breakpoints(1).Unit = 'Nm';
lutControl.Breakpoints(1).FieldName = 'Torque';

Set Breakpoint properties of Dimension 2

lutControl.Breakpoints(2).Name = 'speed';
lutControl.Breakpoints(2).Unit = 'rpm';
lutControl.Breakpoints(2).FieldName = 'Speed';

4. Add lookup table control.

lutControl = maskObj.addDialogControl('Name', 'fuelflowlut', 'Type', 'lookuptablecontrol');

See Also

Simulink.dialog.LookupTableControl| | Simulink.dialog.LookupTableControl.Breakpoints

Related Topics