Page 1 of 1

How do I change the domain of a base type like "double"

PostPosted: Thu Jun 12, 2008 10:53 am
by busser
Simulink Tester provides a set of default data types and low value to high value domains for these types. For example, there is the base type "double" with the domain +/- 1.0e+012. I understand that these values were selected to be large enough to support signals with relatively large maximum or minimum values, while still maintaining a few significant digits to the right of the decimal point. However, sometimes these low and high value limits are too large for some types of computations and constraint relationships, where too much precision is lost due to floating point round off limitations in digital approximations of real number arithmetic. How can I change the default domain limits for base types such as "double" to reduce or expand the domain to accommodate the computations in my model ?

Re: How do I change the domain of a base type like "double"

PostPosted: Thu Jun 12, 2008 11:28 am
by busser
The Simulink Tester signal range editor and translator were originally designed to allow the user to simply modify the domain limits, even for base types such as double. But this caused a number of problems and was deemed to be an unmanageable feature, so support for editing the domain of base types was removed. However, there is an alternative approach that is nearly as easy and has none of the draw backs of simply changing the base type domains. This would be to use the Replace function in the type area of the Signal Range Editor. The process for doing this is as follows.

To effectively change the domain of type double to an alternative low/high limit values, create a new user-defined data type (e.g. new_double) and then change all signals currently defined as being of type double to instead be defined as type new_double.

Step 1. Create a new type called "new_double" with the desired domain.

Create_new_type.png (10.9 KiB) Viewed 4552 times

Step 2. Right click on the base type "double" and select the "Replace" menu item.

Replace_type.png (23.38 KiB) Viewed 4555 times

Step 3. Select "new_double" as the replacement type and click on "OK".

Select_replacement_type.png (20.4 KiB) Viewed 4553 times

Step 4. Confirm the resulting replacement of "double" with "new_double" on all signals that were originally of type "double".

Resulting_replacement.png (17.23 KiB) Viewed 4553 times