state2index
Description
Examples
Find Indices of States in navGraph
Object
Load navGraph
data for states and links.
load navGraphData.mat
Create a table to use to search for the state ID.
stateData = table([3 6 0.142170047601527; 1 1 1],["F"; "A"],[2; 2], ... VariableNames={'StateVector','Name','Lanes'});
Find the indices of the states.
id = findstate(navGraphObj,stateData)
id = 2×1
6
0
The navGraph
states table contains a state corresponding to the first state data, so the function returns its index. However, the states table does not contain a state that corresponds to the second state, so the function returns 0
.
navGraphObj.States
ans=8×3 table
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
stateIDS = state2index(navGraphObj,stateData.StateVector)
stateIDS = 2×1
6
0
Input Arguments
graph
— Graph object
navGraph
object
Graph object, specified as a navGraph
object.
Output Arguments
stateIDS
— State indices
column vector of positive integers
State indices, returned as a column vector of positive integers. When the function
does not find a specified state vector, the value for the corresponding element in
stateIDS
is 0
.
Data Types: double
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2023a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)