read
Read data from GPS
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Syntax
Description
[
returns matrices of measurements from the GPS. This is a non blocking read which
returns N data points in matrix format where N is specified by
lla,groundSpeed,course, dops,gpsReceiverTime,timestamp, overrun] = read(gpsObj)SamplesPerRead and matrix is specified
using OutputFormat property of the gpsdev
object.
Examples
Read Data from GPS
Create an Arduino object and include the Serial library.
a = arduino('COM4', 'Mega2560', 'Libraries', 'Serial');
Create GPS object.
gpsObj = gpsdev(a);
Read samples of GPS data.
tt = read(gpsObj)
tt =
1×5 timetable
Time LLA GroundSpeed Course DOPs GPSReceiverTime
________________________ __________________________ ___________ ______ ____________________ ________________________
31-Jan-2020 11:41:42.475 12.944 77.692 807.7 0.0463 266.6 1.72 0.94 1.44 31-Jan-2020 06:11:42.000Read Data from GPS as a timetable
Create an Arduino object and include the Serial library.
a = arduino('COM4', 'Mega2560', 'Libraries', 'Serial');
Create GPS object with additional properties.
gpsObj = gpsdev(a, "OutputFormat","timetable",'SamplesPerRead',2);
Read samples of GPS data.
[tt,overruns] = read(gpsObj)
tt =
2×5 timetable
Time LLA GroundSpeed Course DOPs GPSReceiverTime
________________________ __________________________ ___________ ______ ____________________ ________________________
31-Jan-2020 11:32:49.459 12.944 77.692 806.8 0.0463 258.87 1.31 0.99 0.85 31-Jan-2020 06:02:49.000
31-Jan-2020 11:32:50.416 12.944 77.692 806.9 0.12861 262.7 1.31 0.99 0.85 31-Jan-2020 06:02:50.000
overrun =
3
Display the time at which GPS data is read from the Arduino hardware in
duration format.
gpsObj.TimeFormat = “duration”; [tt,overruns] = read(gpsObj)
tt =
2×5 timetable
Time LLA GroundSpeed Course DOPs GPSReceiverTime
__________ __________________________ ___________ ______ ____________________ ________________________
9.4257 sec 12.944 77.692 808.4 0.030867 4.93 1.51 0.78 1.29 31-Jan-2020 06:15:24.000
10.404 sec 12.944 77.692 808.4 0.051444 41.26 1.1 0.76 0.79 31-Jan-2020 06:15:25.000
overrun =
755Read Data from GPS as a Matrix
Create an Arduino object and include the Serial library.
a = arduino('COM4', 'Mega2560', 'Libraries', 'Serial');
Create GPS object with additional properties.
gpsObj = gpsdev(a, "OutputFormat","matrix",'SamplesPerRead',2);
Read samples of GPS data.
[lla,speed,course,dops,gpsReceiverTime,timestamp,overruns] = read(gpsObj)
lla =
12.9437 77.6916 807.4000
12.9437 77.6916 807.4000
speed =
0.0154
0.0463
course =
346.0100
270.2100
dops =
1.2400 0.9200 0.8300
1.7700 0.9900 1.4700
gpsReceiverTime =
2×1 datetime array
31-Jan-2020 06:07:01.000
31-Jan-2020 06:07:02.000
timestamp =
2×1 datetime array
31-Jan-2020 11:37:01.734
31-Jan-2020 11:37:02.436
overruns =
75
Input Arguments
Output Arguments
More About
Version History
Introduced in R2020a