MATLAB: Does the custom TLC code not display the correct parameter values in Real-Time Workshop 6.1 (R14SP1)

classdatalimitparameterreferencesrtwsimulink codertlcvalues

I am declaring a data class in the MATLAB workspace. One of the parameters is:
FirstOutputMatrix.Value = ...
[ 1 2 3 4 5 6; ...
11 12 13 14 15 16; ...
21 22 23 24 25 26; ...
31 32 33 34 35 36; ...
41 42 43 44 45 46; ...
51 52 53 54 55 56; ...
];
Using Real-Time Workshop 6.0 (R14), I created the following TLC code, which displayed object parameters.
%function ASAP2UserFcnWriteCharacteristic_Lookup2D(paramGroup) Output
%assign zParam = paramGroup.Member[2].Reference
%selectfile STDOUT
ObjectProperties(zParam) = %<FcnGetObjectProperties(zParam)>
%selectfile NULL_FILE
In R14, the "Value" parameter was displayed correctly. However, in Release 14, Service Pack 1 (R14SP1), the "Value" parameter is returned empty. If I redefine "Value" as a 3×3 matrix, it displays correctly in R14SP1.

Best Answer

This bug has been fixed in Release 2006a (R2006a). For previous product releases, read below for any possible workarounds:
As of Release 14, Service Pack 1 (R14SP1), Real-Time Workshop uses REFERENCES instead of VALUES for any parameter that has more than 10 elements. This can lead to problems when you try to access the parameter values directly from TLC. MathWorks recommends that you not access parameter values directly in TLC.
Currently, to work around this issue, increase the threshold required for Real-Time Workshop to use REFERENCE instead of VALUE. The default threshold is 10.
You can adjust the threshold by specifying a value for RTWDataReferencesMinSize with set_param at the MATLAB command prompt. For example, the following command sets the threshold to 20.
set_param(0,'RTWDataReferencesMinSize',20)
This setting enables any parameter consisting of up to 19 elements to be expanded in the TLC file. If you use larger parameters, set RTWDataReferencesMinSize accordingly.
If you choose to use this workaround, consider the following:
- The workaround works on a per MATLAB session basis. Real-Time Workshop overwrites and resets RTWDataReferencesMinSize to the default value of 10 for each session unless you have a mechanism for automatically overriding the default (for example, a startup.m file). More information on the startup options is available in the documentation:
web([docroot '/techdoc/matlab_env/start_q4.html'])
You can copy and paste the above command into the MATLAB command window to display the documentation.
- The workaround is not memory efficient and is not recommended if the parameter value size is greater than 20 elements.