Main Content

nodes

Define component nodes, that is, conserving ports of block

Parent Section: component | domain

Syntax

nodes
    a = namespace_name.domain_name;
end

Description

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

  • In a component file, this section contains declarations for the component nodes, which correspond to the conserving ports of a Simscape™ block generated from the component file. Each node is defined by assignment to an existing domain. For more information, see Declare Component Nodes.

  • In a domain file, this section contains declarations for the composite domain nodes. Each node represents a bundle of connections, possibly of different types. For more information, see Composite Domains.

Component Nodes

In a component file, this syntax defines a node, a, by associating it with a domain, domain_name. namespace_name is the full path to the domain, starting with the top namespace folder. For more information on organizing your Simscape files, see Building Custom Block Libraries.

nodes
    a = namespace_name.domain_name;
end

You can specify the port label, the way you want it to appear in the block diagram, as a comment:

nodes
    a = namespace_name.domain_name;  % label
end

where label is a string corresponding to the port name in the block diagram. You can use the Side annotation to specify the port location on the block icon. For more information, see Customize the Names and Locations of the Block Ports.

You can also declare nodes as resizable arrays of elements that all belong to the same domain type. For more information, see Arrays of Nodes.

Domain Nodes

In a domain file, use the nodes section to declare a composite domain as a hierarchy of other, primitive or composite, domains. A primitive domain is a regular Foundation or custom domain that is defined by its Through and Across variables. A composite domain is a textual equivalent of a bus port on a rigid Simscape Bus block. Composite domain nodes represent a bundle of connections, possibly of different types.

A composite domain cannot declare inputs, outputs, variables, parameters, or equations. The only section allowed is nodes.

Composite domain nodes can refer to:

  • Foundation domains.

  • Primitive custom domains.

  • Other composite domains.

Restrictions on member nodes inside the nodes section in a composite domain declaration:

  • Must be public.

  • Conditional declarations are not allowed.

  • Cannot be parameterized. Parameterizing a node in a component file makes this component a source for domain parameter propagation in the network. For more information, see Source Components. In a domain file, such parameterization is meaningless.

In a primitive domain file, the nodes section is not allowed.

Examples

expand all

This example declares a node associated with the Simscape Foundation mechanical rotational domain:

nodes
    r = foundation.mechanical.rotational.rotational;
end

The name of the top-level namespace folder is +foundation. It contains a subnamespace +mechanical, with a subnamespace +rotational, which in turn contains the domain file rotational.ssc.

To declare a node associated with your own customized rotational domain, called rotational.ssc and located at the top level of your custom namespace folder +MechanicalElements, use this syntax:

nodes
    r = MechanicalElements.rotational;
end

The name of the top-level namespace folder is +foundation. It contains a subnamespace +mechanical, with a subnamespace +rotational, which in turn contains the domain file rotational.ssc.

Components using your own customized rotational domain cannot be connected with the components using the Simscape Foundation mechanical rotational domain. Use your own customized domain definitions to build complete libraries of components to be connected to each other.

This example declares an electrical node associated with the Simscape Foundation electrical domain:

nodes
    p = foundation.electrical.electrical; % +
end
annotations
    p : Side = top;
end

In a custom block generated from this component, the conserving electrical port will be labelled + and located on the top side of the block icon.

To declare an internal node, that is, a node that exists in the component but does not show up on the block icon, use the attribute setting (ExternalAccess=none):

nodes (ExternalAccess=none)
    Tm = foundation.thermal.thermal; 
end

For more information, see Attribute Lists.

This example declares an array of thermal nodes associated with the Simscape Foundation thermal domain. The array size is an adjustable parameter that the block users can modify.

parameters
     N = 20; % Number of nodes
end
for i=1:N
   nodes 
      H(i) = foundation.thermal.thermal;
   end 
end

This example declares a composite domain that combines two primitive domain types: mechanical translational and electrical.

domain MechElec
% Mechanical Translational and Electrical Domain
    nodes
        m = foundation.mechanical.translational.translational;
        e = foundation.electrical.electrical;
    end
end

Version History

Introduced in R2008b