Main Content

rmstate

Remove one or more states from graph

Since R2024a

Description

rmstate(graph,stateIDs) removes states specified by state identifiers and the associated links from the input graph.

example

rmstate(graph,names) removes states specified by state names and the associated links from the input graph.

example

Examples

collapse all

Load navGraph object into MATLAB® workspace and inspect its properties.

load("navGraphData.mat")
disp(navGraphObj)
  navGraph with properties:

           States: [8x3 table]
            Links: [7x3 table]
    LinkWeightFcn: @nav.algs.distanceEuclidean

Inspect the states table of the input graph.

disp(navGraphObj.States)
          StateVector          Name     Lanes
    _______________________    _____    _____

    8          2    0.72176    {'A'}      2  
    1          1    0.29188    {'B'}      2  
    7          7    0.91777    {'C'}      2  
    8         10    0.71458    {'D'}      2  
    5          1    0.54254    {'E'}      2  
    3          6    0.14217    {'F'}      2  
    2          9    0.37334    {'G'}      3  
    8          7    0.67413    {'H'}      2  

Display the input graph.

show(navGraphObj)

Figure contains an axes object. The axes object contains an object of type graphplot.

Specify State Identifiers to Remove States

Specify the indices of the states in the states table that you want to remove from the graph.

rmstate(navGraphObj,[4;5])

Inspect the updated states table for the states that are removed from the graph.

disp(navGraphObj.States)
          StateVector          Name     Lanes
    _______________________    _____    _____

    8          2    0.72176    {'A'}      2  
    1          1    0.29188    {'B'}      2  
    7          7    0.91777    {'C'}      2  
    3          6    0.14217    {'F'}      2  
    2          9    0.37334    {'G'}      3  
    8          7    0.67413    {'H'}      2  

Display the updated graph.

show(navGraphObj)

Figure contains an axes object. The axes object contains an object of type graphplot.

Specify State Names to Remove States

Specify the names of the states you want to remove from the graph.

rmstate(navGraphObj,{"B";"D";"F"})

Inspect the updated states table for the states that are removed from the graph.

disp(navGraphObj.States)
          StateVector          Name     Lanes
    _______________________    _____    _____

    8          2    0.72176    {'A'}      2  
    7          7    0.91777    {'C'}      2  
    2          9    0.37334    {'G'}      3  
    8          7    0.67413    {'H'}      2  

Display the updated graph.

show(navGraphObj)

Figure contains an axes object. The axes object contains an object of type graphplot.

Input Arguments

collapse all

Graph object, specified as a navGraph object.

State identifiers, specified as a column vector of positive integers. State identifiers represent the indices of the states in the states table of the input graph.

State names, specified as a column vector of strings, column vector of characters, cell array of strings, or cell array of characters. The number of rows must be equal to the number of states, and the value of each row must be unique.

Data Types: char | string | cell

Extended Capabilities

Version History

Introduced in R2024a