Why do I get an error when I use a Mask variable as the name of a Data Store Memory variable inside a masked subsystem in Simulink 7.9 (R2012a)?

9 views (last 30 days)
I have a masked subsystem in Simulink 7.9 (R2012a) which has a parameter 'VarName' which a user can enter into the block mask.
I have created a Simulink.Signal object in my workspace named "Test_Variable", and I entered this same variable name into the Mask parameter for my block. However, I get the following error when I try updating this model:
Data store memory with name 'VarName' was not found for block 'Model_Name/Masked Subsystem/Data Store Write'
Is there any way to get around this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 10 Sep 2012
The reason why the Data Store Memory is not working as expected is because the block itself expects a string into the Data Store Name field. Therefore, no matter what the mask variable VarName is set to, the Data Store Memory block looks for a variable named 'VarName' rather than the actual value of VarName.
There are two steps to work around this issue:
1. Enter the variable name as a string in the Mask Parameters. So, when you double-click on the block you should enter 'Test_Variable' rather than Test_Variable.
2. Add these lines of MATLAB code to the Mask Initialization tab of the block to set the value of the Data Store Memory's name to the value of VarName. These lines are:
blk = [gcb '/Data Store Write'];
set_param(blk,'DataStoreName',VarName)
This ensures that VarName is used as a variable and not as the string 'VarName'.

More Answers (0)

Products


Release

R2012a

Community Treasure Hunt

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

Start Hunting!