Main Content


Verify and extract NMEA sentence data into string array



[isValid,splitString] = extractNMEASentence(unparsedData,'MessageID') 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, splitString.


Use extractNMEASentence to Obtain NMEA Fields of NMEA Sentence

Suppose that the Message ID of the NMEA sentence from which you need to extract data as split strings is GLL. You provide an unparsed GLL sentence as input, and specify the Message ID to extract the NMEA sentence into string array.

unparsedData = ['$GPGLL,1300.26049,N,07733.81639,E,074549.00,A,A*6C'];
[isValid, splitString] = extractNMEASentence(unparsedData,'GLL')
isValid =



splitString = 

  1×9 string array

    "GP"    "GLL"    "1300.26049"    "N"    "07733.81639"    "E"    "074549.00"    "A"    "A"

Input Arguments

collapse all

The unparsed NMEA data as obtained from the device.

The Message ID to identify the unparsed NMEA sentence.

Output Arguments

collapse all

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

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

See Also


Introduced in R2021b