Simulink: How to display S-function parameters in mask
Displaying the raw parameters string
If you have 1.23 'Test text'
as parameter string in your S-function Block Parameters
dialog, you can use the following code to display it in the mask:
display_sfunction_params_mask.m
params = get_param(gcb(), 'Parameters')
disp(params)
Displaying parsed parameters
Parsing the parameters in the same way Simulink does internally is quite involved. This is a simple solution I found, but it doesnt work if the parameter values contain spaces.
parse_sfunction_params_mask.m
raw_params = get_param(gcb(), 'Parameters')
params = split(string(raw_params))
disp("1st param: " + params{1} + ", 2nd param: " + params{2})
Check out similar posts by category:
Matlab/Simulink
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow