Is there a way to programmatically get list of valid values/datatypes for Simulink block parameter?

11 次查看(过去 30 天)
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?
For example, Delay dialog box parameters 'ShowEnablePort' which can only be set to 'on' or 'off'.

回答(1 个)

Paul
Paul 2021-10-13
编辑:Paul 2021-10-13
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.

类别

Help CenterFile Exchange 中查找有关 Simulink Environment Customization 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by