Main Content

index2state

Find state vectors of state indices

Since R2023a

    Description

    states = index2state(graph,stateIDS) finds the state vectors states for the queried state indices stateIDS, if they exist in the navGraph object graph.

    example

    Examples

    collapse all

    Load navGraph data for states and links.

    load navGraphData.mat

    Visualize the navGraph object.

    show(navGraphObj);

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

    Find successive state indices and costs based on a state name.

    [succIDS,costs] = successors(navGraphObj,"G")
    succIDS = 2×1
    
         1
         8
    
    
    costs = 2×1
    
       38.7759
       13.9383
    
    

    Find the state vectors of the successive states.

    states = index2state(navGraphObj,succIDS)
    states = 2×3
    
        8.0000    2.0000    0.7218
        8.0000    7.0000    0.6741
    
    

    Input Arguments

    collapse all

    Graph object, specified as a navGraph object.

    State indices, specified as a column vector of positive integers.

    Data Types: single | double

    Output Arguments

    collapse all

    State vectors, returned as a matrix in which each row represents a state vector. The state vectors must be of the same size as those in the StateVector column of the States table in the navGraph object graph.

    Data Types: double

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2023a