Commit b955b20b authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Modified @dynSeries/minus method so that dynSeries objects defined over...

Modified @dynSeries/minus method so that dynSeries objects defined over different non disjoint periods can be substracted.
parent 63502db6
...@@ -54,16 +54,12 @@ else ...@@ -54,16 +54,12 @@ else
end end
end end
if ~isequal(B.nobs,C.nobs)
error(['dynSeries::plus: Cannot substract ' inputname(1) ' and ' inputname(2) ' (wrong number of observations)!'])
end
if ~isequal(B.freq,C.freq) if ~isequal(B.freq,C.freq)
error(['dynSeries::plus: Cannot substract ' inputname(1) ' and ' inputname(2) ' (frequencies are different)!']) error(['dynSeries::plus: Cannot substract ' inputname(1) ' and ' inputname(2) ' (frequencies are different)!'])
end end
if ~isequal(B.init,C.init) if ~isequal(B.nobs,C.nobs) || ~isequal(B.init,C.init)
error(['dynSeries::plus: Cannot substract ' inputname(1) ' and ' inputname(2) ' (initial dates are different)!']) [B, C] = align(B, C);
end end
if isempty(B) if isempty(B)
...@@ -118,3 +114,31 @@ A.data = bsxfun(@minus,B.data,C.data); ...@@ -118,3 +114,31 @@ A.data = bsxfun(@minus,B.data,C.data);
%$ end %$ end
%$ T = all(t); %$ T = all(t);
%@eof:1 %@eof:1
%@test:3
%$ % Define a datasets.
%$ A = rand(10,2); B = randn(5,1);
%$
%$ % Define names
%$ A_name = {'A1';'A2'}; B_name = {'B1'};
%$
%$ t = zeros(5,1);
%$
%$ % Instantiate a time series object.
%$ try
%$ ts1 = dynSeries(A,[],A_name,[]);
%$ ts2 = dynSeries(B,[],B_name,[]);
%$ ts3 = ts1-ts2;
%$ t(1) = 1;
%$ catch
%$ t = 0;
%$ end
%$
%$ if length(t)>1
%$ t(2) = dyn_assert(ts3.vobs,2);
%$ t(3) = dyn_assert(ts3.nobs,10);
%$ t(4) = dyn_assert(ts3.data,[A(1:5,1)-B(1:5), A(1:5,2)-B(1:5) ; NaN(5,2)],1e-15);
%$ t(5) = dyn_assert(ts3.name,{'minus(A1,B1)';'minus(A2,B1)'});
%$ end
%$ T = all(t);
%@eof:3
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment