GPS NMEA String Parsing in simulink EML
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am pulling GPS NMEA strings into a MicroAutoBoxII (MABII) and need to parse the latitude and longitude data from the string. I am trying to use the strfind() in an eml with the buffered serial data.
StringS = uint8(['$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47 '])
%Get the Start Location of the string
StartLoc = matchtext(char(StringS)','$GPGGA')
%This works and returns the starting string location
if(StartLoc > 0) %This fails as it calls the value of StartLoc a Matlab type
%Find latitude string location
a = matchtext(char(StringS(StartLoc:200)),'N');
end
function TextPosition = matchtext(sx,SearchKey)
eml.extrinsic('strfind');
TextPosition = double(strfind(sx,SearchKey));
_
The error that is returned is in reference to the if statement:
Expected either a logical, char, int, fi, single, or double. Found a MATLAB type. MATLAB types are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may be used on the right-hand side of assignments and as arguments to MATLAB calls._
I liked the strfind function and makes it easy to pull the string apart but it won't allow me to use the returned index value to index an array. Also tried recasting the type but failed.
Also if there are any other suggestions for different functions would be helpful. Currently working on a solution using the find function and identifying individual characters to select data from the string as I don't believe I can use it to find a sequence.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!