get_param - Get system and block parameter values

Syntax

get_param('obj', 'parameter')
get_param( { objects }, 'parameter')
get_param(handle, 'parameter')
get_param(0, 'parameter')
get_param('obj', 'ObjectParameters')
get_param('obj', 'DialogParameters')

Description

get_param('obj', 'parameter'), where 'obj' is a system or block pathname, returns the value of the specified parameter. Some parameters are case-sensitive, and some are not. To prevent problems, treat all parameters as case-sensitive.

get_param( { objects }, 'parameter') accepts a cell array of full path specifiers, enabling you to get the values of a parameter common to all objects specified in the cell array.

get_param(handle, 'parameter') returns the specified parameter of the object whose handle is handle.

get_param(0, 'parameter') returns the current value of a Simulink® session parameter or the default value of a model or block parameter.

get_param('obj', 'ObjectParameters') returns a structure that describes obj's parameters. Each field of the returned structure corresponds to a particular parameter and has the parameter's name. For example, the Name field corresponds to the object's Name parameter. Each parameter field itself contains three fields, Name, Type, and Attributes, that specify the parameter's name (for example, 'Gain'), data type (for example, string), and attributes (for example, read-only), respectively.

get_param('obj', 'DialogParameters') returns a cell array containing the names of the dialog parameters of the specified block.

Model and Block Parameters contains lists of model and block parameters.

Examples

This command returns the value of the Gain parameter for the Inertia block in the Requisite Friction subsystem of the clutch system.

get_param('clutch/Requisite Friction/Inertia','Gain')
ans =
   1/(Iv+Ie)

These commands display the block types of all blocks in the mx + b system (the current system), described in Masked Subsystem Example in Using Simulink®.

blks = find_system(gcs, 'Type', 'block');
listblks = get_param(blks, 'BlockType')

listblks = 

    'SubSystem'
    'Inport'
    'Constant'
    'Gain'
    'Sum'
    'Outport'

This command returns the name of the currently selected block.

get_param(gcb, 'Name')

The following commands get the attributes of the currently selected block's Name parameter.

p = get_param(gcb, 'ObjectParameters');
a = p.Name.Attributes

ans = 
    'read-write'    'always-save'

The following command gets the dialog parameters of a Sine Wave block.

p = get_param('untitled/Sine Wave', 'DialogParameters')
p = 
          SineType: [1x1 struct]
        TimeSource: [1x1 struct]
         Amplitude: [1x1 struct]
              Bias: [1x1 struct]
         Frequency: [1x1 struct]
             Phase: [1x1 struct]
           Samples: [1x1 struct]
            Offset: [1x1 struct]
        SampleTime: [1x1 struct]
    VectorParams1D: [1x1 struct]

See Also

find_system, set_param

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS