Bugs in tscollection class?

조회 수: 1 (최근 30일)
Evgeny Pr
Evgeny Pr 2011년 5월 29일
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
Titus Edelhofer
Titus Edelhofer 2011년 5월 30일
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 2011년 5월 30일
Then it's a documentation enhancement and not a bug (but I would make it a code enhancement to case INsensitive)

댓글을 달려면 로그인하십시오.

답변 (1개)

Oleg Komarov
Oleg Komarov 2011년 5월 29일
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));

카테고리

Help CenterFile Exchange에서 Time Series Collections에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by