nazar.kitsak
nazar.kitsak

Reputation: 70

Control Masks Programmatically for Simulink block

I have a problem with simulink block properties. I need to check if block has parameter with name "paramName". If this parameter is absent I need to add it. For this I want to get mask parameters:

p = Simulink.Mask.get(blockName);

This example I get from help. But Simulink show following error:

undefined variable "Simulink" or class "Simulink.Mask.get"

What should I do for solving my problem?

Upvotes: 0

Views: 2934

Answers (1)

am304
am304

Reputation: 13876

You probably need to use get_param in combination with the DialogParameters property, e.g.:

block_params = get_param(%block_path%,`DialogParameters`);

The output block_params is a structure with all the parameters of that particular block. Replace %block_path% by the path to the block in question or use gcb for the current block. There is an example on the documentation page for get_param:

Get a Block Parameter Value and Attributes

List the block parameter names for the Inertia block in the Requisite Friction subsystem of the sldemo_clutch model.

block_params = get_param('sldemo_clutch/Friction Mode Logic/Requisite Friction/Inertia Ratio',... 'DialogParameters') 

ans = 
                                          Gain: [1x1 struct]
                             Multiplication: [1x1 struct]
                                 ParamMin: [1x1 struct]
                                ParamMax: [1x1 struct]
                  ParamDataTypeStr: [1x1 struct]
                                     OutMin: [1x1 struct]
                                    OutMax: [1x1 struct]
                      OutDataTypeStr: [1x1 struct]
                                LockScale: [1x1 struct]
                                  RndMeth: [1x1 struct]
    SaturateOnIntegerOverflow: [1x1 struct]
                             SampleTime: [1x1 struct]

Upvotes: 2

Related Questions