Added broadcasting when assigning new data to a dynSeries object.

*Examples*

 * ts.A(qq(1950,1):qq(1950,4)) = 1 will put ones for variable A in periods 1950Q1 to 1950Q4

 * ts{'A','B'}(qq(1950,1):qq(1950,4)) = 1 will put ones for variables A and B in periods 1950Q1 to 1950Q4

 * ts{'A','B'}(qq(1950,1):qq(1950,4)) = ones(4,1) will put ones(4,1) for variables A and B and sub-periods 1950Q1-1950Q4

 * ts{'A','B'}(qq(1950,1):qq(1950,4)) = ones(1,2) will put ones(1,2) for variables A and B and each period between 1950Q1 and 1950Q4
time-shift
Stéphane Adjemian (Charybdis) 2013-07-03 14:54:05 +02:00
parent 84522ce87f
commit 55ea513f74
1 changed files with 9 additions and 1 deletions

View File

@ -167,11 +167,19 @@ switch length(S)
if isequal(length(tdx),rows(B))
if isequal(columns(sA.data),columns(B))
sA.data(tdx,:) = B;
elseif isequal(size(B,2),1)
sA.data(tdx,:) = repmat(B,1,columns(sA.data));
else
error('dynSeries::subsasgn: Dimension error! The number of variables on the left and right hand side must match.')
end
else
error('dynSeries::subsassgn: Dimension error! The number of periods on the left and right hand side must match.')
if isequal(columns(sA.data),columns(B)) && isequal(rows(B),1)
sA.data(tdx,:) = repmat(B,length(tdx),1);
elseif isequal(rows(B),1)
sA.data(tdx,:) = B
else
error('dynSeries::subsassgn: Dimension error! The number of periods on the left and right hand side must match.')
end
end
else
error('dynSeries::subsasgn: The object on the right hand side must be a dynSeries object or a numeric array!')