-
Notifications
You must be signed in to change notification settings - Fork 3
Sync
ds.Sync
ds.Sync(syncType)
timeNew = ds.Sync(__)
ds.Sync
Re-samples all loaded channels of the datasource (ds
) to have the sample sampling rate using linear interpolation.
ds.Sync(syncType)
Changes what sampling rate is used when re-sampling the loaded channels (defaults to fast
)
syncType | Description |
---|---|
fast |
Selects the highest sampling rate (Shortest Period) used by loaded channels |
slow |
Selects the lowest sampling rate (Longest Period) used by loaded channels |
cheap |
Selects the sampling rate used by the largest number of loaded channels |
timeNew = ds.Sync(__)
Returns a time vector showing the sampling time in seconds for all loaded channels using the new sampling rate
Sync is used to overcome the issue of differing sampling rate across channels preventing element-wise operations on channel data.
For example suppose Engine_RPM
is logged at 5 Hz and Engine_Torque
is logged at 20Hz. This creates an issue when computing the torque of the engine as there 4 time more samples for Engine_Torque
than Engine_RPM
and will cause the following statements to error:
%Throws Error: Matrix dimensions must agree
ds.getChannel('Engine_RPM').Value + ds.getChannel('Engine_Torque').Value
ds.getChannel('Engine_RPM').Value - ds.getChannel('Engine_Torque').Value
ds.getChannel('Engine_RPM').Value .* ds.getChannel('Engine_Torque').Value
ds.getChannel('Engine_RPM').Value ./ ds.getChannel('Engine_Torque').Value
By using ds.Sync
all loaded channels (See ds.loadChannel
) will be linearly re-sampled so that all channels have the same number of samples. The re-sampling process will have the following effect on the logged data:
Sample Rate | Effect |
---|---|
Equal to New Sampling Rate | No Effect |
Less than the New Sampling Rate | New samples will be created by linearly interpolating between old samples at the new sampling rate |
Greater than the New Sampling Rate | New samples will be created by linearly interpolating between old samples at the new sampling rate |
Note: Most of the time the new sampling rate will be an integer multiple/divisor of the old sampling rate. In this case some of the original samples will be retained, with new samples created or original samples removed as needed. However in the case of a non integer multiple/divisor, the re-sampled channel will be largely created via linear interpolation.
Once loaded channels have been synced, element-wise or array operations (See Array vs. Matrix Operations) can be used.
- Access Methods
- Helper Methods
- Graphing Methods