Specify component parameters
parameters comp_par1 = { value , 'unit' }; end
Component parameters let you specify adjustable parameters for the Simscape™ block generated from the component file. Parameters will appear in the block dialog box and can be modified when building and simulating a model.
parameters
begins a component parameters
definition block, which is terminated by an end
keyword.
This block contains declarations for component parameters. Parameters
will appear in the block dialog box when the component file is brought
into a Simscape model. Each parameter is defined as a value with unit.
Specifying an optional comment lets you control the parameter name
in the block dialog box.
The following syntax defines a component parameter, comp_par1
,
as a value with unit. value
is the initial value.
unit
is a valid unit string, defined in the unit
registry.
parameters comp_par1 = { value , 'unit' }; end
To declare a unitless parameter, you can either use the same syntax:
par1 = { value , '1' };
or omit the unit and use this syntax:
par1 = value;
Internally, however, this parameter will be treated as a two-member
value-unit array { value , '1' }
.
You can specify the parameter name, the way you want it to appear in the block dialog box, as a comment:
parameters comp_par1 = { value , 'unit' }; % Parameter name end
The following example declares parameter k
,
with a default value of 10 N*m/rad
, specifying
the spring rate of a rotational spring. In the block dialog box, this
parameter will be named Spring rate.
parameters k = { 10 'N*m/rad' }; % Spring rate end