Main Content

parameters

Declare domain or component parameters

Parent Section: component | domain

Syntax

parameters
    par1 = {value,'unit'};
end

Description

parameters begins a parameters declaration section, which is terminated by an end keyword:

  • In a component file, this section contains declarations for the component parameters. Component parameters let you specify adjustable parameters for the Simscape™ block generated from the component file. Parameters appear in the block dialog box and can be modified when building and simulating a model.

  • In a domain file, this section contains declarations for the domain parameters. The main purpose of domain parameters is to propagate the same parameter value to all or some of the components connected to the domain.

You declare each parameter as a value with unit:

parameters
    par1 = {value,'unit'};
end

value is the initial parameter value. unit is a valid unit string, defined in the unit registry.

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 is treated as a two-member value-unit array {value,'1'}.

For component parameters, adding a comment after the parameter declaration lets you specify the parameter name, the way you want it to appear in the block dialog box:

parameters
    comp_par1 = {value,'unit'}; % Parameter name
end

Examples

expand all

This example declares a component parameter k, with a default value of 10 N*m/rad, specifying the spring rate of a rotational spring. In the block dialog box and Property Inspector, this parameter will be named Spring rate.

parameters
    k = {10,'N*m/rad'};   % Spring rate
end

The purpose of domain parameters is to propagate the same parameter value to all or some of the components connected to the domain. For example, this hydraulic domain contains one Across variable, p, one Through variable, q, and one parameter, t.

domain t_hyd
  variables
    p = {1e6,'Pa'}; % pressure
  end
  variables(Balancing = true)
    q = {1e-3,'m^3/s'}; % flow rate
  end
  parameters
    t = {303,'K'}; % fluid temperature
  end
end

All components with nodes connected to this domain will have access to the fluid temperature parameter t and can use this parameter in their equations.

Version History

Introduced in R2008b