extractNMEASentence
Description
[
verifies the checksum of an unparsed NMEA sentence, identified using its Message ID,
and extracts the NMEA fields from NMEA sentence data into a string array,
isValid
,splitString
] = extractNMEASentence(unparsedData
,'MessageID
')splitString
.
Examples
Extract NMEA Fields of NMEA Sentence
Provide unparsed GGA, GSA, and RMC sentences as the input.
unparsedGGALine = '$GPGGA,111357.771,5231.364,N,01324.240,E,1,12,1.0,0.0,M,0.0,M,,*69'; unparsedGSALine = '$GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30'; unparsedRMCLine = '$GPRMC,111357.771,A,5231.364,N,01324.240,E,10903,221.5,020620,000.0,W*44';
Create a string array to include the three sentences
unparsedNMEAData = [unparsedGGALine,newline,unparsedGSALine,newline,unparsedRMCLine]
unparsedNMEAData = '$GPGGA,111357.771,5231.364,N,01324.240,E,1,12,1.0,0.0,M,0.0,M,,*69 $GPGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*30 $GPRMC,111357.771,A,5231.364,N,01324.240,E,10903,221.5,020620,000.0,W*44'
Specify GSA as the Message ID to extract the NMEA fields from the NMEA sentence into string array.
[isValid, splitString] = extractNMEASentence(unparsedNMEAData,'GSA')
isValid = logical
1
splitString = 1x19 string
"GP" "GSA" "A" "3" "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "11" "12" "1.0" "1.0" "1.0"
Input Arguments
unparsedData
— Unparsed NMEA data from the device
string | character array
The unparsed NMEA data as obtained from the device.
MessageID
— Message ID of the unparsed NMEA sentence
string | character array
The Message ID to identify the unparsed NMEA sentence.
Output Arguments
isValid
— Validity of unparsed NMEA sentence based on checksum
0
| 1
Determine the validity of unparsed NMEA sentence based on checksum. A
value of 1
indicates that the checksum is valid. A value
of 0
indicates that the checksum is invalid; however, the
fields of NMEA sentence appear in the splitString
output
if the specified MessageID is matching.
Data Types: logical
splitString
— Output data as split strings
string array
Output data as split strings based on the structure that you defined. If
the specified MessageID is not found in the NMEA sentence, the function
returns an empty splitString
.
Data Types: string
Version History
Introduced in R2021b
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 (한국어)