Main Content

nodes

Define component nodes, that is, conserving ports of block

Parent Section: component

Syntax

nodes
    a = namespace_name.domain_name;
end

Description

nodes begins a nodes declaration section, which is terminated by an end keyword. 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. See Declare Component Nodes for more information.

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

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

Version History

Introduced in R2008b