Is there a way to programmatically get list of valid values/datatypes for Simulink block parameter?
5 views (last 30 days)
Show older comments
Simulink Block Specific parameters documentation lists the values and/or datatype each parameter of the block accept. Is there an api or function that allows us to get this information programmatically?
0 Comments
Answers (1)
Paul
on 13 Oct 2021
Edited: Paul
on 13 Oct 2021
I'm not sure that this can be done in general. But for dialog parameters that areof type 'enum', the options can be obtained by:
>> d=get_param(gcb,'DialogParameters')
d =
struct with fields:
DelayLengthSource: [1×1 struct]
DelayLength: [1×1 struct]
DelayLengthUpperLimit: [1×1 struct]
InitialConditionSource: [1×1 struct]
InitialCondition: [1×1 struct]
ExternalReset: [1×1 struct]
ShowEnablePort: [1×1 struct]
PreventDirectFeedthrough: [1×1 struct]
DiagnosticForDelayLength: [1×1 struct]
RemoveDelayLengthCheckInGeneratedCode: [1×1 struct]
InputProcessing: [1×1 struct]
UseCircularBuffer: [1×1 struct]
SampleTime: [1×1 struct]
StateName: [1×1 struct]
StateMustResolveToSignalObject: [1×1 struct]
StateSignalObject: [1×1 struct]
StateStorageClass: [1×1 struct]
CodeGenStateStorageTypeQualifier: [1×1 struct]
>> d.DelayLengthSource
ans =
struct with fields:
Prompt: 'Delay length source:'
Type: 'enum'
Enum: {'Dialog' 'Input port'}
Attributes: {'read-write' 'read-only-if-compiled' 'dont-eval' 'link-instance'}
>> d.DelayLengthSource.Enum
ans =
1×2 cell array
{'Dialog'} {'Input port'}
For parameters of type 'boolean', I'll just conjecture that the choices are either 'on' or 'off'.
For parameters of type 'string' I don't know what to say:
>> d.DelayLength
ans =
struct with fields:
Prompt: 'Delay length:'
Type: 'string'
Enum: {}
Attributes: {'read-write' 'read-only-if-compiled' 'link-instance'}
I don't know and couldn't find in doc if there are any other types of dialog parameters.
0 Comments
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!