How can I read data from a GPS device into MATLAB?
4 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Commented: Robert
on 5 Nov 2016
I have an NMEA-compliant GPS device, and I want to use it to stream GPS data into MATLAB. It seems like a great compliment to the Mapping Toolbox.
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
You can communicate with a GPS device in MATLAB via a serial connection (COM port). Many GPS devices will expose a virtual COM port when plugged into a USB port. You can then connect to it using the SERIAL function in MATLAB. For example:
gps = serial('COM1');
fopen(gps);
% Read a line of text from the input stream
data = fgetl(gps);
% [Other processing]
% Close the connection
fclose(gps);
delete(gps);
See the attached function, which shows your current location on Google Maps, for a more detailed example.
1 Comment
Robert
on 5 Nov 2016
You did not answer your own question correctly It says how to stream data in. Not simply poll for data. You gave an example of how to poll data, not how to stream it in.
More Answers (0)
See Also
Categories
Find more on Downloads in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!