Parameterizing Composite Components
Composite component parameters let you adjust the desired parameters of the underlying member components from the top-level block dialog box when building and simulating a model.
Specify the composite component parameters by declaring a corresponding
parameter in the top-level parameters declaration
block, and then assigning it to the desired parameter of a member
component. The declaration syntax is the same as described in Declare Component Parameters.
For example, the following code includes a Foundation library Resistor block in your custom component file, with the ability to control the resistance at the top level and a default resistance of 10 Ohm:
component MyCompositeModel
[...]
parameters
p1 = {10, 'Ohm'};
[...]
end
components(ExternalAccess=observe)
r1 = foundation.electrical.elements.resistor(R = p1);
[...]
end
[...]
end
You do not have to assign all the parameters of member blocks to top-level parameters. If a member block parameter does not have a corresponding top-level parameter, the composite model uses the default value of this parameter, specified in the member component.