MATLAB: Warning when using Mask Callbacks in a Linked block.

simulink

Warning message when trying to update a parameter in the mask using mask callbacks.
Warning: "the value "RED" of the mask parameter "enumselected" for the block "comparetoenum" is not valid."
This only happens when using blocks from the library link.
I just changed the enumeration type to basic colors, changed the enumeration to Brown, saved the model.
When you open it, you get the warning:
*Model Load*
1
Clear
08:45 AM Elapsed: 0.245 sec
The value 'RED' of the mask parameter 'enumSelected' for the block '< trial/CompareToEnum>' is not valid.
Component:Simulink | Category:Block warning

Best Answer

The reason why the warning is occurring is because once you set the enumeration to a different value from the one in the Library block, then save it and close it, and when you reopen the model, it first gets the enum value from the library block which is instantiated to the original value, this value mismatch triggers the warning to be generated.
Once the model is opened and the calback is executed, it updates the the enum value to the modified value but at this point the warning has already been generated.
So the generated warning is expected behavior. You can get rid of the warning by disabling the library link but then you won't get the advantages of using a library block. To disable the library links:
Right click on the Mask block -> go to Library Link -> Click on Disable Link.
It is generally not a best practice to use callbacks when using linked blocks.
Please refer to the following documentation for more information about using Linked blocks: