put_in_sur_form: simplify function and make robust to potential future changes in dseries
parent
a3867a0b34
commit
874ba9a641
|
@ -66,18 +66,17 @@ for i = 1:neqs
|
||||||
to_remove = [];
|
to_remove = [];
|
||||||
nr = sum(nobs(1:i-1));
|
nr = sum(nobs(1:i-1));
|
||||||
nxcol = size(X{i}, 2);
|
nxcol = size(X{i}, 2);
|
||||||
Xtmp = dseries([zeros(nr, nxcol); X{i}.data; zeros(nrows-nr-nobs(i), nxcol)], fd, X{i}.name);
|
names = X{i}.name;
|
||||||
for j = 1:length(X{i}.name)
|
Xtmp = dseries([zeros(nr, nxcol); X{i}.data; zeros(nrows-nr-nobs(i), nxcol)], fd, names);
|
||||||
idx = find(strcmp(Xmat.name, X{i}.name{j}));
|
Xmatnames = Xmat.name;
|
||||||
|
for j = 1:length(names)
|
||||||
|
idx = find(strcmp(Xmatnames, names{j}));
|
||||||
if ~isempty(idx)
|
if ~isempty(idx)
|
||||||
Xmat.(Xmat.name{idx}) = Xmat{idx} + Xtmp{j};
|
Xmat.(Xmatnames{idx}) = Xmat.(Xmatnames{idx}) + Xtmp.(names{j});
|
||||||
to_remove = [to_remove j];
|
Xtmp = Xtmp.remove(names{j});
|
||||||
constrained{end+1} = Xmat.name{idx};
|
constrained{end+1} = Xmatnames{idx};
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for j = length(to_remove):-1:1
|
|
||||||
Xtmp = Xtmp.remove(Xtmp.name{to_remove(j)});
|
|
||||||
end
|
|
||||||
if ~isempty(Xtmp)
|
if ~isempty(Xtmp)
|
||||||
Xmat = [Xmat Xtmp];
|
Xmat = [Xmat Xtmp];
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue