MATLAB: Do I get the error “Invalid setting in ‘/‘ for parameter ‘‘.” when calling set_param

simulink

Why do I get the error "Invalid setting in '<model>/<block>' for parameter '<param>'." when calling set_param using the following line of code?
set_param('my_model/Constant', 'Value', 0);

Best Answer

When using set_param for the "Value" field of a Constant block, use a character array instead of a double, which is evaluated to the actual value.
This is true of many parameters on other blocks as well.
This is fixed by making the following modification:
set_param('my_model/Constant', 'Value', '0');
Note that the 0 is enclosed in single quotes, making it a character array.