-
Notifications
You must be signed in to change notification settings - Fork 3
loadChannel
ds.loadChannel(channelName)
ds.loadChannel(channelName)
Loads channel data for the channels given by channelName
from the datasource's *.MAT file into memory. channelName
can be a string if only one channel needs to be loaded or a cell array of channel names to load multiple channels.
Note: ds
is a single datasource not the array of datasources typically returned by dm.getDatasource
The datasource returned by ds = dm.getDatasource
preload the channel data from their *.MAT file into memory rather that data is only loaded when requested by loadChannel
, so as to not waste time loading unnecessary data into the working memory.
Additionally when using loadChannel
it is advisable to load all channels at once rather than load them one at a time. As loading channel data all at once will be on average 2.17 times faster than loading channels one by one, as demonstrated by the following script:
%Grab a datasource
dm = Datamaster;
ds = dm.getDatasource('limit', 1);
%Initalize counter arrays
one = []; all = [];
%Run multiple iterations
for i = 1:1000
%Clear datasource
ds.clearData
%Pick a method at random
if rand > 0.5
tic
ds.loadChannel('Engine_RPM')
ds.loadChannel('Throttle_Pos')
ds.loadChannel('Manifold_Pres')
one(end+1) = toc;
else
tic
ds.loadChannel({'Engine_RPM';'Throttle_Pos';'Manifold_Pres'})
all(end+1) = toc;
end
end
%Report Results
fprintf('Load all at once: %f stdev: %f n: %d\n', mean(all), std(all), length(all));
fprintf('Load one by one: %f stdev: %f n: %d\n', mean(one), std(one), length(one));
fprintf('Speed up of: %1.2fx\n', mean(one) /mean(all));
This speed up can become significant when conducting analysis using hundreds of datasources, especially when the Datastore is not located on a local drive.
Note: ds.getChannel
will call ds.loadChannel
as needed and thus the use of ds.loadChannel
is optional. However this is not advised due to the significant speed penalty.
- Access Methods
- Helper Methods
- Graphing Methods