Main Content

remove

Remove data from sensor data object

Since R2024b

Description

remove(sensorDataObj,Timestamp=timestamps) removes sensor data for the specified timestamps timestamps from the sensor data object sensorDataObj.

example

remove(sensorDataObj,Timestamp=timestamps,TimeTol=timeTol) removes sensor data for the specified timestamps timestamps, with a tolerance time, timeTol, from the sensor data object sensorDataObj.

remove(sensorDataObj,RowIndices=rowIndices) removes sensor data for the specified row indices rowIndices from the sensor data object sensorDataObj.

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.

example

Examples

collapse all

Load recorded GPS data into the workspace.

load("recordedGPSData.mat")

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

gpsData = scenariobuilder.GPSData(timestamps,latitudes,longitudes,altitudes)
gpsData = 
  GPSData with properties:

          Name: ''

    NumSamples: 392
      Duration: 19.5498
    SampleRate: 20.0513
    SampleTime: 0.0500
    Timestamps: [392×1 double]

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

    Attributes: []

Plot waypoints in the GPS data object.

plot(gpsData)

Extract the timestamps for the data you want to remove from the GPS data object.

t = timestamps(1:100);

Remove the data from the GPS data object for the extracted timestamps.

remove(gpsData,Timestamp=t)

Display the GPS data object after data removal.

disp(gpsData)
  GPSData with properties:

          Name: ''

    NumSamples: 292
      Duration: 14.5500
    SampleRate: 20.0687
    SampleTime: 0.0500
    Timestamps: [292×1 double]

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

    Attributes: []

Plot the GPS data object, and observe where waypoints have been removed.

figure
plot(gpsData)

Specify row indices for which to remove data from the gpsData object.

idxs = 1:100;

Remove the data from the GPS data object for the specified row indices.

remove(gpsData,RowIndices=idxs)

Display the GPS data object after data removal.

disp(gpsData)
  GPSData with properties:

          Name: ''

    NumSamples: 192
      Duration: 9.5493
    SampleRate: 20.1063
    SampleTime: 0.0500
    Timestamps: [192×1 double]

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

    Attributes: []

Plot the GPS data object, and observe where waypoints have been removed.

figure
plot(gpsData)

Load recorded GPS data into the workspace.

load("recordedGPSData.mat","X","Y","Z","timestamps")

Create a Trajectory object by using the loaded timestamps and xyz-coordinates.

traj = scenariobuilder.Trajectory(timestamps,X,Y,Z)
traj = 
  Trajectory with properties:

               Name: ''

         NumSamples: 392
           Duration: 19.5498
         SampleRate: 20.0513
         SampleTime: 0.0500
         Timestamps: [392×1 double]

           Position: [392×3 double]
        Orientation: [392×3 double]
           Velocity: [392×3 double]
             Course: [392×1 double]
        GroundSpeed: [392×1 double]
       Acceleration: [392×3 double]
    AngularVelocity: [392×3 double]

        LocalOrigin: [0 0 0]
         TimeOrigin: 0

         Attributes: []

Plot the trajectory object.

plot(traj)

Extract the timestamps of the data you want to remove the from the trajectory object.

t = timestamps(1:100);

Remove the data from the trajectory object for the extracted timestamps.

remove(traj,Timestamp=t)

Display the trajectory object.

disp(traj)
  Trajectory with properties:

               Name: ''

         NumSamples: 292
           Duration: 14.5500
         SampleRate: 20.0687
         SampleTime: 0.0500
         Timestamps: [292×1 double]

           Position: [292×3 double]
        Orientation: [292×3 double]
           Velocity: [292×3 double]
             Course: [292×1 double]
        GroundSpeed: [292×1 double]
       Acceleration: [292×3 double]
    AngularVelocity: [292×3 double]

        LocalOrigin: [0 0 0]
         TimeOrigin: 0

         Attributes: []

Plot the trajectory object, and observe where waypoints have been removed.

plot(traj)

Input Arguments

collapse all

Sensor data, specified as a GPSData object, Trajectory object, CameraData object, or a LidarData object.

Timestamps for which to remove sensor data, specified as a nonnegative scalar, M-element numeric column vector, an M-element datetime array, or an M-element duration array. M is the number of timestamps. The datatype of the timestamps value and the datatype of the Timestamps property of the input sensor data object sensorDataObj must be the same. If you specify a positive scalar or an M-element numeric column vector, units must be in seconds. Each element in the timestamps argument specifies the time at which the GPS data was collected.

When you remove sensor data, the sensor data object sensorDataObj arranges the data in the increasing order of the timestamps.

Row indices of the sensor data to remove, specified as a positive integer or an M-element column vector of positive integers. M is the number of rows of the sensorDataObj input from which to remove data. Values must be in the range [1, NumSamples], where NumSamples is the number of samples in the input sensor data object sensorDataObj.

Data Types: single | double | uint8 | uint16 | uint32 | uint64

Tolerance time to read data, specified as a nonnegative scalar. Units are in seconds. The function removes data samples for each timestamps in the interval, timestamps-timeTol to timestamps+ timeTol. Increasing the tolerance time increases the number samples in the sensor data object sensorDataObj.

Data Types: single | double

Version History

Introduced in R2024b