Main Content

intermediates

Define intermediate terms for use in equations

Parent Section: component | domain

Syntax

intermediates
    int_term1 = expr1;
end

Description

intermediates begins an intermediates declaration block, which is terminated by an end keyword. In a component file, this block contains declarations of named intermediate terms for use in equations. You can reuse these intermediate terms in any equations section of the same component or an enclosing composite component.

You can also include an intermediates section in a domain file and reuse these intermediate terms in any component that has nodes of that domain type.

When you use an intermediate term in an equation, the equation substitutes the intermediate term with the expression that it refers to. Think of an intermediate term as of defining an alias for an expression.

intermediates
    int_term1 = expr1;
end

Declaring intermediate terms helps with code reuse and readability. For example, if you declare hydraulic diameter and critical Reynolds number as intermediate terms in an isothermal liquid component, you can then use these terms throughout the component equations.

You can specify a descriptive name for an intermediate term, by using a comment, similar to the way you do it for parameters and variables:

intermediates
    int_term1 = expr1; % Descriptive name
end

If you include the intermediate term in logged simulation data, this descriptive name appears in the Simscape™ Results Explorer. You can also specify a preferred data logging unit for intermediate terms by using the LoggingUnit annotation. For more information, see Specify Preferred Logging Unit for an Intermediate.

Examples

expand all

This example declares the intermediate term for the hydraulic diameter, D_h, as a function of the orifice area. It also specifies a descriptive name for use in simulation data logging, Hydraulic diameter.

intermediates
    D_h  = sqrt( 4.0 * A / pi ); % Hydraulic diameter
end

This example declares the same intermediate term, D_h, as in the previous example, but prevents it from appearing in simulation data logs:

intermediates(ExternalAccess = none)
    D_h  = sqrt( 4.0 * A / pi ); 
end

Version History

Introduced in R2018b