Main Content

intermediates

Define intermediate terms for use in equations

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 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.

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 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:

intermediates
    int_term1 = expr1; % Descriptive name
end

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

Examples

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

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

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 ); 
end

Version History

Introduced in R2018b