# initializeTrack

Initialize new track

## Syntax

``trackID = initializeTrack(obj,track)``
``trackID = initializeTrack(obj,track,filter)``

## Description

example

````trackID = initializeTrack(obj,track)` initializes a new track in the tracker or track fuser object, `obj`. The tracker or fuser must be updated at least once before initializing a track. If the track is initialized successfully, the tracker or fuser assigns the output `trackID` to the track, sets the `UpdateTime` of the track equal to the last step time in the tracker, and synchronizes the data in the input `track` to the initialized track. A warning is issued if the tracker or track fuser already maintains the maximum number of tracks specified by its`MaxNumTracks` property. In this case, the `trackID` is returned as `0`, which indicates a failure to initialize the track. NoteThis syntax doesn't support using the `trackingGSF`, `trackingPF`, or `trackingIMM` filter object as the internal tracking filter for the tracker or track fuser. Use the second syntax in these cases. ```
````trackID = initializeTrack(obj,track,filter)` initializes a new track in the tracker or track fuser object, `obj`, using a specified tracking filter, `filter`. NoteIf the tracking filter used in the tracker or track fuser is `trackingGSF`, `trackingPF`, or `trackingIMM`, you must use this syntax instead of the first syntax.This syntax does not support using `trackFuser` as the `obj` input. ```

## Examples

collapse all

Create a GNN tracker and update the tracker with detections at $\mathit{t}=0$ and $\mathit{t}=1$second.

`tracker = trackerGNN`
```tracker = trackerGNN with properties: TrackerIndex: 0 FilterInitializationFcn: 'initcvekf' MaxNumTracks: 100 MaxNumDetections: Inf MaxNumSensors: 20 Assignment: 'MatchPairs' AssignmentThreshold: [30 Inf] AssignmentClustering: 'off' OOSMHandling: 'Terminate' TrackLogic: 'History' ConfirmationThreshold: [2 3] DeletionThreshold: [5 5] HasCostMatrixInput: false HasDetectableTrackIDsInput: false StateParameters: [1x1 struct] NumTracks: 0 NumConfirmedTracks: 0 ClassFusionMethod: 'None' EnableMemoryManagement: false ```
```detection1 = objectDetection(0,[1;1;1]); detection2 = objectDetection(1,[1.1;1.2;1.1]); tracker(detection1,0); currentTrack = tracker(detection2,1);```

As seen from the `NumTracks` property, the tracker now maintains one track.

`tracker`
```tracker = trackerGNN with properties: TrackerIndex: 0 FilterInitializationFcn: 'initcvekf' MaxNumTracks: 100 MaxNumDetections: Inf MaxNumSensors: 20 Assignment: 'MatchPairs' AssignmentThreshold: [30 Inf] AssignmentClustering: 'off' OOSMHandling: 'Terminate' TrackLogic: 'History' ConfirmationThreshold: [2 3] DeletionThreshold: [5 5] HasCostMatrixInput: false HasDetectableTrackIDsInput: false StateParameters: [1x1 struct] NumTracks: 1 NumConfirmedTracks: 1 ClassFusionMethod: 'None' EnableMemoryManagement: false ```

Create a new track using the `objectTrack` object.

`newTrack = objectTrack()`
```newTrack = objectTrack with properties: TrackID: 1 BranchID: 0 SourceIndex: 1 UpdateTime: 0 Age: 1 State: [6x1 double] StateCovariance: [6x6 double] StateParameters: [1x1 struct] ObjectClassID: 0 ObjectClassProbabilities: 1 TrackLogic: 'History' TrackLogicState: 1 IsConfirmed: 1 IsCoasted: 0 IsSelfReported: 1 ObjectAttributes: [1x1 struct] ```

Initialize a track in the GNN tracker object using the newly created track.

`trackID = initializeTrack(tracker,newTrack)`
```trackID = uint32 2 ```

As seen from the `NumTracks` property, the tracker now maintains two tracks.

`tracker`
```tracker = trackerGNN with properties: TrackerIndex: 0 FilterInitializationFcn: 'initcvekf' MaxNumTracks: 100 MaxNumDetections: Inf MaxNumSensors: 20 Assignment: 'MatchPairs' AssignmentThreshold: [30 Inf] AssignmentClustering: 'off' OOSMHandling: 'Terminate' TrackLogic: 'History' ConfirmationThreshold: [2 3] DeletionThreshold: [5 5] HasCostMatrixInput: false HasDetectableTrackIDsInput: false StateParameters: [1x1 struct] NumTracks: 2 NumConfirmedTracks: 2 ClassFusionMethod: 'None' EnableMemoryManagement: false ```

## Input Arguments

collapse all

New track to be initialized, specified as an `objectTrack` object or a structure. If specified as a structure, the name, variable type, and data size of the fields of the structure must be the same as the name, variable type, and data size of the corresponding properties of the `objectTrack` object.

Data Types: `struct` | `object`

## Output Arguments

collapse all

Track identifier, returned as a nonnegative integer. `trackID` is returned as 0 if the `track` is not initialized successfully.

Example: `2`

## Version History

Introduced in R2020a