Bugs in tscollection class?

2 Ansichten (letzte 30 Tage)
Evgeny Pr
Evgeny Pr am 29 Mai 2011
I found that in class TSCOLLECTION the method ADDTS has two bugs in subfunction "localUnitConv". Or am I mistaken?
But what is it?
function convFactor = localUnitConv(outunits,inunits)
try
% Get available units
availableUnits = {'weeks', 'days', 'hours', 'minutes', 'seconds',...
'milliseconds', 'microseconds', 'nanoseconds'};
factors = [604800 86400 3600 60 1 1e-3 1e-6 1e-9];
indIn = find(strcmp(inunits,availableUnits)); % ??? Case Insensitive is lost?
if isempty(indIn)
return % ??? convFactor is not defined!
end
factIn = factors(indIn);
indOut = find(strcmp(outunits,availableUnits)); % ???
if isempty(indOut)
return % ???
end
factOut = factors(indOut);
convFactor = factIn/factOut;
catch me %#ok<NASGU>
% ??? Exception does not work if convFactor is not define!
convFactor = 1; % Return 1 if error or unknown units
end
For example:
ts1 = timeseries(rand(5,1),[1 2 3 4 5], 'Name', 'ts1')
ts1.TimeInfo.Units = 'Days'
ts2 = timeseries(rand(5,1),[1 2 3 4 5], 'Name', 'ts2')
ts2.TimeInfo.Units = 'Days'
tsc = tscollection({ts1, ts2})
Oops...
---------
Error in ==> tscollection.addts>localUnitConv at 190 try
??? Output argument "convFactor" (and maybe others) not assigned during call to "C:\Programs\MATLAB\R2010b\toolbox\matlab\timeseries\@tscollection\addts.m>localUnitConv".
Error in ==> tscollection.addts>localCheckTS at 131 tsIntimevec = localUnitConv(h.TimeInfo.Units,ts.TimeInfo.Units)*ts.Time;
Error in ==> tscollection.addts at 78 localCheckTS(h,data{i});
Error in ==> tscollection.init at 103 this = this.addts(tsCellArray);
Error in ==> tscollection.tscollection>tscollection.tscollection at 50 this = init(this,varargin{:});
----------
Am I doing something wrong, or is it a bad testing?
  2 Kommentare
Titus Edelhofer
Titus Edelhofer am 30 Mai 2011
Hi,
as far as I can see, the doc of tscollection gives all timeinfo in lower case, i.e., 'days' instead of 'Days'. Then it should work. I haven't seen somewhere in the doc that it should be case insensitive ...
Titus
Oleg Komarov
Oleg Komarov am 30 Mai 2011
Then it's a documentation enhancement and not a bug (but I would make it a code enhancement to case INsensitive)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Oleg Komarov
Oleg Komarov am 29 Mai 2011
Use 'days' (non capitalized)
You can change:
indIn = find(strcmp(inunits,availableUnits));
indOut = find(strcmp(outunits,availableUnits));
to
indIn = find(strcmpi(inunits,availableUnits));
indOut = find(strcmpi(outunits,availableUnits));

Kategorien

Mehr zu Time Series Collections finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by