Main Content

add

Add data to GPS data object

Since R2024b

Description

add(gpsData,timestamps,latitude,longitude,altitude) adds the specified GPS data latitude, longitude, and altitude, with their corresponding timestamps timestamps, to the GPS data object gpsData.

example

add(___,Attributes=attributes) specifies optional GPS attributes attributes to the specified GPS data object in addition to the input arguments from the previous syntax.

Note

This function requires the Scenario Builder for Automated Driving Toolbox™ support package. You can install the Scenario Builder for Automated Driving Toolbox support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

Examples

collapse all

Load recorded GPS data into the workspace.

load("recordedGPSData.mat")

Initialize a GPSData object using the information from the GPS data.

idx = 100;
gpsData = scenariobuilder.GPSData(timestamps(1:idx), ...
                latitudes(1:idx),longitudes(1:idx),altitudes(1:idx), ...
                Name="GPSSensor")
gpsData = 
  GPSData with properties:

          Name: "GPSSensor"

    NumSamples: 100
      Duration: 4.9492
    SampleRate: 20.2054
    SampleTime: 0.0500
    Timestamps: [100×1 double]

      Latitude: [100×1 single]
     Longitude: [100×1 single]
      Altitude: [100×1 single]

    Attributes: []

Plot the GPS data object.

plot(gpsData)

Add additional data samples to the GPS data object.

add(gpsData,timestamps(idx+1:end),latitudes(idx+1:end), ...
        longitudes(idx+1:end),altitudes(idx+1:end))

Plot the GPS data object, and observe the added waypoints.

figure
plot(gpsData)

Input Arguments

collapse all

GPS data, specified as a GPSData object.

Timestamps of the added GPS data, specified as an N-element numeric column vector, an N-element datetime array, or an N-element duration array. N is the number of timestamps. The data type of the timestamps argument and the data type of the Timestamps property of the input GPSData object gpsData must be the same. If you specify an N-element numeric column vector, units must be in seconds. Each element in the timestamps argument specifies the time at which the corresponding GPS data was collected.

The add function arranges the added GPS data points by their timestamps, in increasing order.

Latitude coordinates of the added GPS data, specified as an N-element numeric column vector. N is the number of timestamps. Units are in degrees.

Data Types: double

Longitude coordinates of the added GPS data, specified as an N-element numeric column vector. N is the number of timestamps. Units are in degrees.

Data Types: double

Altitude coordinates of the added GPS data, specified as an N-element numeric column vector. N is the number of timestamps. Units are in meters.

Data Types: double

Optional GPS attributes of added GPS data, specified as an N-by-1 cell array. N is the number of timestamps. Each cell contains the additional GPS attributes, such as velocity and speed values, recorded at the corresponding timestamp.

Data Types: cell

Version History

Introduced in R2024b