主要内容

addNodes

Add wireless nodes to wireless network viewer

Since R2026a

    Description

    addNodes(networkViewer,pos) adds the specified wireless nodes pos to the wireless network viewer, networkViewer.

    addNodes(networkViewer,pos,Name=Value) specifies node-related configuration parameters using one or more optional name-value arguments.

    Examples

    collapse all

    Generate and visualize the random placement of wireless nodes within a rectangular area. Using the nodePositionRandom function, you distribute ten nodes uniformly inside a 100-by-100 meter region. Then, a wirelessNetworkViewer object displays the resulting node positions.

    Set the area dimensions and number of nodes.

    areaLength = 100;           % Rectangle length (meters)
    areaWidth = 100;            % Rectangle width (meters)
    numNodes = 10;              % Number of random nodes

    Generate random node positions in the rectangle.

    [nodePositions,rectPoly] = nodePositionRandom( ...
        "rectangle",[areaLength areaWidth],NumNodes=numNodes);

    View the positions using the wireless network viewer.

    viewer = wirelessNetworkViewer(CanvasSize=[200 200]);
    addNodes(viewer,nodePositions,Type="RandomNodePositions")

    Show the rectangle boundary.

    showBoundary(viewer, ...
        Position=[0 0 0], ...
        BoundaryShape="rectangle", ...
        Bounds=[areaLength areaWidth], ...
        Name="RectangleBoundary")

    Figure Wireless Network Viewer contains an axes object. The axes object with xlabel X-axis (m), ylabel Y-axis (m) contains 22 objects of type line. One or more of the lines displays its values using only markers These objects represent Canvas Boundary, RandomNodePositions, Boundary.

    Remove the node position by uncommenting this line of code.

    % removeNodes(viewer)

    Hide the rectangle boundary by uncommenting this line of code.

    % hideBoundary(viewer)

    Input Arguments

    collapse all

    Wireless network viewer, specified as a wirelessNetworkViewer object.

    Nodes or node positions, specified as one of these options.

    • A vector of objects of a subclass of wnet.Node.

    • A cell array of objects of a subclass of wnet.Node.

    • An N-by-3 matrix of node position values, where N is the number of node positions. Specify each position in 3-D Cartesian coordinates, in meters.

    Name-Value Arguments

    collapse all

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Example: addNodes(networkViewer,[0 1 3],Type="Node A") sets the type of the wireless node to "Node A".

    Type of the wireless node, specified as a string scalar or character vector.

    Data Types: string | char

    Node name, specified as a string scalar, a vector of strings, or a character vector.

    Data Types: string | char

    Version History

    Introduced in R2026a