Main Content


Define intermediate terms for use in equations


intermediates int_term1 = expr1; end     


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 of 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 an intermediate term is used in an equation, it is ultimately substituted with the expression that it refers to. Think of an intermediate term as of defining an alias for an expression.

    int_term1 = expr1;

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

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

    int_term1 = expr1; % Descriptive name

Then, if you include the intermediate term in logged simulation data, this descriptive name appears in the Simscape™ Results Explorer.


This example declares the intermediate term D_h (hydraulic diameter) as a function of the orifice area:

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

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

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

Version History

Introduced in R2018b