# Documentation

Specify name, value, units, and other properties of Simulink dual-scaled parameter

## Description

This class extends the Simulink.Parameter class so that you can define an object that stores two scaled values of the same physical value. For example, for temperature measurement, you can store a Fahrenheit scale and a Celsius scale with conversion defined by a computational method that you provide. Given one scaled value, the Simulink.DualScaledParameter computes the other scaled value using the computational method.

A dual-scaled parameter has:

• A calibration value. The value that you prefer to use.

• A main value. The real-world value that Simulink® uses.

• An internal stored integer value. The value that is used in the embedded code.

You can use Simulink.DualScaledParameter objects in your model for both simulation and code generation. The parameter computes the internal value before code generation via the computational method. This offline computation results in leaner generated code.

If you provide the calibration value, the parameter computes the main value using the computational method. This method can be a first-order rational function.

$y=\frac{ax+b}{cx+d}$

• x is the calibration value.

• y is the main value.

• a and b are the coefficients of the CalToMain compute numerator.

• c and d are the coefficients of the CalToMain compute denominator.

If you provide the calibration minimum and maximum values, the parameter computes minimum and maximum values of the main value. Simulink performs range checking of parameter values. The software alerts you when the parameter object value lies outside a range that corresponds to its specified minimum and maximum values and data type.

You can use the Simulink.DualScaledParameter dialog box to define a Simulink.DualScaledParameter object. To open the dialog box:

1. In the Model Explorer, select the base workspace or a model workspace and select Add > Add Custom.

2. In the Model Explorer — Select Object dialog box, set Object class to Simulink.DualScaledParameter.

## Property Dialog Box

### Calibration Attributes Tab

Calibration value

Calibration value of the parameter. The value that you prefer to use. The default value is [] (unspecified). Specify a finite, real, double value.

Before specifying Calibration value, you must specify CalToMain compute numerator and CalToMain compute denominator to define the computational method. The parameter uses the computational method and the calibration value to calculate the main value that Simulink uses.

Calibration minimum

Minimum value for the calibration parameter. The default value is [] (unspecified). Specify a finite, real, double scalar value.

Before specifying Calibration minimum, you must specify CalToMain compute numerator and CalToMain compute denominator to define the computational method. The parameter uses the computational method and the calibration minimum value to calculate the minimum or maximum value that Simulink uses. A first order rational function is strictly monotonic, either increasing or decreasing. If it is increasing, setting the calibration minimum sets the main minimum value. If it is decreasing, setting the calibration minimum sets the main maximum.

If the parameter value is less than the minimum value or if the minimum value is outside the range of the parameter data type, Simulink generates a warning. In these cases, when updating the diagram or starting a simulation, Simulink generates an error.

Calibration maximum

Maximum value for the calibration parameter. The default value is [] (unspecified). Specify a finite, real, double scalar value.

Before specifying Calibration maximum, you must specify CalToMain compute numerator and CalToMain compute denominator to define the computational method. The parameter uses the computational method and the calibration maximum value to calculate the corresponding maximum or minimum value that Simulink uses. A first order rational function is strictly monotonic, either increasing or decreasing. If it is increasing, setting the calibration maximum sets the main maximum value. If it is decreasing, setting the calibration maximum sets the main minimum.

If the parameter value is less than the minimum value or if the minimum value is outside the range of the parameter data type, Simulink generates a warning. In these cases, when updating the diagram or starting a simulation, Simulink generates an error.

CalToMain compute numerator

Specify the numerator coefficients a and b of the first-order linear equation:

$y=\frac{ax+b}{cx+d}$

The default value is [] (unspecified). Specify finite, real, double scalar values for a and b. For example, [1 1] or, for reciprocal scaling, 1.

Once you have applied CalToMain compute numerator, you cannot change it.

CalToMain compute denominator

Specify the denominator coefficients c and d of the first-order linear equation:

$y=\frac{ax+b}{cx+d}$

The default value is [] (unspecified). Specify finite, real, double scalar values for c and d. For example, [1 1].

Once you have applied CalToMain compute denominator, you cannot change it.

Calibration name

Specify the name of the calibration parameter. The default value is ''. Specify a string value, for example, 'T1'.

Calibration units

Specify the measurement units for this calibration value. This field is intended for use in documenting this parameter. The default value is ''. Specify a string value, for example, 'Fahrenheit'.

Is configuration valid

Simulink indicates whether the configuration is valid. The default value is true. If Simulink detects an issue with the configuration, it sets this field to false and provides information in the Diagnostic message field. You cannot set this field.

Diagnostic message

If you specify invalid parameter settings, Simulink displays a message in this field. Use the diagnostic information to help you fix an invalid configuration issue. You cannot set this field.

## Properties

Name

Access

Description

CalibrationValue

RW

Calibration value of this parameter. (Calibration value)

CalibrationMin

RW

Calibration minimum value of this parameter. (Calibration minimum)

CalibrationMax

RW

Calibration maximum value of this parameter. (Calibration maximum)

CalToMainCompuNumerator

RW

Numerator coefficients of the computational method. (CalToMain compute numerator)

Once you have applied CalToMainCompuNumerator, you cannot change it.

CalToMainCompuDenominator

RW

Denominator coefficients of the computational method. (CalToMain compute denominator)

Once you have applied CalToMainCompuDenominator, you cannot change it.

CalibrationName

RW

Name of the calibration parameter. (Calibration name)

CalibrationDocUnits

RW

Measurement units for this calibration parameter's value. (Calibration units)

IsConfigurationValid

RO

Information about validity of configuration. (Is configuration valid)

DiagnosticMessage

RO

If the configuration is invalid, diagnostic information to help you fix the issue. (Diagnostic message)

## Example

### Create and Update a Dual-Scaled Parameter

Create a Simulink.DualScaledParameter object that stores a temperature as both Fahrenheit and Celsius.

Set the computational method that converts between Fahrenheit and Celsius.

Temp.CalToMainCompuNumerator = [1 -32];
Temp.CalToMainCompuDenominator = [1.8];

Set the value of the temperature that you want to see in Fahrenheit.

Temp.CalibrationValue = 212
Temp =

DualScaledParameter with properties:

CalibrationValue: 212
CalibrationMin: []
CalibrationMax: []
CalToMainCompuNumerator: [1 -32]
CalToMainCompuDenominator: 1.8000
CalibrationName: ''
CalibrationDocUnits: ''
IsConfigurationValid: 1
DiagnosticMessage: ''
Value: 100
Description: ''
DataType: 'auto'
Min: []
Max: []
Unit: ''
Complexity: 'real'
Dimensions: [1 1]

The Simulink.DualScaledParameter calculates Temp.Value which is the value that Simulink uses. Temp.CalibrationValue is 212 (degrees Fahrenheit), so Temp.Value is 100 (degrees Celsius).

Name the value and specify the units.

Temp.CalibrationName = 'TempF';
Temp.CalibrationDocUnits = 'Fahrenheit';

Set calibration minimum and maximum values.

Temp.CalibrationMin = 0;
Temp.CalibrationMax = 300;

If you specify a calibration value outside this allowable range, Simulink generates a warning.

Specify the units that Simulink uses.

Temp.Unit = 'degC';

open Temp

The Calibration Attributes tab displays the calibration value and the computational method that you specified.

In the dialog box, click the Main Attributes tab.

Get trial now