function D = loadDataSet(fileName) %loadDataSet Load a single data point. % D = loadDataSet(fileName) returns a 'struct' D % containing the following fields: % Current - a timeseries object % Voltage - a timeseries object % TimeOffset - initial time instant (sec) % You can usually ignore the TimeOffset field: when % loading the data, we automatically remove the TimeOffset % from the TimeSeries object to make plotting easier, so % it's just for completeness. narginchk(1, 1); DataSet = load(fileName); % Align start of record to origin. timeOffset = DataSet.t(1); DataSet.t = DataSet.t - timeOffset; % Create a pair of timeseries objects. Current = timeseries(-DataSet.I, DataSet.t/3600); Current.Name = 'Load Current'; Current.DataInfo.Unit = 'amperes'; Current.TimeInfo.Unit = 'hours'; Voltage = timeseries(DataSet.V, DataSet.t/3600); Voltage.Name = 'Load Voltage'; Voltage.DataInfo.Unit = 'volts'; Voltage.TimeInfo.Unit = 'hours'; % Combine the timeseries objects as a struct. D = struct('Current', Current, 'Voltage', Voltage, ... 'TimeOffset', timeOffset, 'FileName', fileName);