How do I update my MATLAB code that checks for certain Simulink message identifiers from an older release to Simulink 7.6 (R2010b)?

1 view (last 30 days)
I have a code that uses Simulink message identifier for its execution. This used to work in earlier releases but does not work with Simulink 7.6 (R2010b).
For example, the code below does not work as expected in Simulink 7.6 (R2010b):
try
out = sim(modelName);
catch e
if isequal(e.identifier, 'Simulink:SL_SetParamWriteOnly')
out = sim(altModelName);
else
rethrow(e);
end
end
I would like to update my code so that it works on both versions.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 12 Jun 2019
Edited: MathWorks Support Team on 12 Jun 2019
To update the MATLAB code that checks Simulink message identifiers from earlier releases to Simulink 7.6 (R2010b), check the attached document for a table consisting of mapping between old and new identifiers.
In order to find the new identifier, you can save the attached file on the MATLAB path and use code similar to the following:
[old,new] = textread('OldNewIdMap.txt','%s %s');
ix = find(strcmp(old,'Simulink:SL_EnumTypePrecisionLossDuringConversion'));
newID =new{ix} % new identifier string
Here is example code that will work in Simulink 7.6 (R2010b) and earlier versions:
try
out = sim(modelName);
catch e
if verLessThan('simulink','7.6')
expectedIdentifier = 'Simulink:SL_SetParamWriteOnly';
else
expectedIdentifier = 'Simulink:Commands:SetParamWriteOnly';
end
if isequal(e.identifier, expectedIdentifier)
out = sim(altModelName);
else
rethrow(e);
end
end

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2010b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!