1
votes

In Simulink, I can get value of a block dialogue parameter that is already given using get_param function. However, I'm interested in finding possible valid values that a block dialogue parameter accepts. For example, The Sum block accepts any combination of + and - signs only for its Inputs parameter. Is there a way to programmatically figure out this information?

To clarify, I want a function/method where I can pass as input a Simulink Block's name and a dialog parameter of that block. For example, I will pass Sum as a Simulink block name and Inputs as a parameter of that block.

What I expect as output is, + and - characters, so that I understand I can only use + and - characters for this block's Inputs parameter.

The page Block-specific Parameters lists the valid (and default) values for different Simulink blocks' parameters in the Values column of each table. Is there a way to find this information programmatically i.e. passing a block type/handler in some function and getting the validation rules for a particular parameter of that block?

Thanks!

2
I'd be very surprised if you can do this in any generic way. Many parameters can be specified as MATLAB variable names, so just getting the name from the dialog isn't going to tell you anything. Even for the sum block the user can specify an integer, not just +'s and -'s.Phil Goddard
Thanks. I did not know that the Sum block's Inputs parameter accepts integers, till I checked the documentation page of the block. It looks like going through individual block's documentation is the best (or only?) way, as not all information is available in this page "Block-specific Parameters" I linked in my question.Shafiul

2 Answers

3
votes

If you take a look at the possibilities to check parameters in C MEX S-Functions it is "free" implemented C code which checks the parameters. At least for such cases there is no way to get a set of accepted parameters. The only possibility is to test pragmatically if a special value is accepted:

value_to_test='++9'
old=get_param('s1/Add','Inputs')
try
set_param('s1/Add','Inputs',value_to_test);
accepted=true;
set_param('s1/Add','Inputs',old);
except
accepted=false;
end
0
votes

Beside the already suggested solution, you can check this out for a Gain block:

dlgParams = get_param(gcbh, 'DialogParameters');
dlgParams.Gain.Validity
%A struct with all accepted data, like: datatype, complexity, sign
dlgParams.Gain.Validity.Sign
%Returns: {'positive'  'negative'  'zero'}

This looks promising. However, a similar property is not available for Sum block. you can check the (dlgParams.Inputs) struct for ideas though.

Writing as an answer since I can't comment yet.