This should be possible if you take two steps inside the S-function:
- You need to make the dialog parameters tuneable run-time parameters (This is a little bit complicated, but is covered by the documentation).
- You need to add a "mdlCheckParameters" function. This is an optional function for S-functions in general, but is likely required in your situation. Essentially, this function gets called when the S-function's dialog parameters get changed, and it provides you with an opportunity to "do whatever you need to do" (e.g. to validate the new values and propagate the effects of the changes to the rest of your code).
Although "mdlCheckParameters" will be called directly, it is also common and valid for your "mdlInitializeSizes" function to call it too, so that you don't have to have redundant code for validating the dialog parameters. (You don't generally call "mdlCheckParameters" blindly from "mdlInitializeSizes", because sometimes "mdlInitializeSizes" is being called just for propagating sizes, but there is an example in the documentation about the right checks to do in this case.)