Changed cumfix==0: splits non-additive components proportionally to size of shock contribution

time-shift
Marco Ratto 2019-12-19 22:15:04 +01:00
parent 1b0e5c2a36
commit aa50724379
1 changed files with 10 additions and 4 deletions

View File

@ -305,16 +305,22 @@ for j=1:nvar
end end
ztmp=squeeze(za(j,:,:)); ztmp=squeeze(za(j,:,:));
if cumfix==0 if cumfix==0
zscale = sum(ztmp(1:end-1,:))./ztmp(end,:); zres = ztmp(end,:) - sum(ztmp(1:end-1,:));
ztmp(1:end-1,:) = ztmp(1:end-1,:)./repmat(zscale,[nterms-1,1]); w = abs(ztmp(1:end-1,:))./sum(abs(ztmp(1:end-1,:)));
ztmp(1:end-1,:) = ztmp(1:end-1,:) + repmat(zres,[nterms-1 1]).*w;
% zscale = sum(ztmp(1:end-1,:))./ztmp(end,:);
% ztmp(1:end-1,:) = ztmp(1:end-1,:)./repmat(zscale,[nterms-1,1]);
else else
zres = ztmp(end,:)-sum(ztmp(1:end-1,:)); zres = ztmp(end,:)-sum(ztmp(1:end-1,:));
ztmp(1:end-1,:) = ztmp(1:end-1,:) + repmat(zres,[nterms-1 1])/(nterms-1); ztmp(1:end-1,:) = ztmp(1:end-1,:) + repmat(zres,[nterms-1 1])/(nterms-1);
end end
gztmp=squeeze(gza(j,:,:)); gztmp=squeeze(gza(j,:,:));
if cumfix==0 if cumfix==0
gscale = sum(gztmp(1:end-1,:))./ gztmp(end,:); gres = gztmp(end,:) - sum(gztmp(1:end-1,:));
gztmp(1:end-1,:) = gztmp(1:end-1,:)./repmat(gscale,[nterms-1,1]); w = abs(gztmp(1:end-1,:))./sum(abs(gztmp(1:end-1,:)));
gztmp(1:end-1,:) = gztmp(1:end-1,:) + repmat(gres,[nterms-1 1]).*w;
% gscale = sum(gztmp(1:end-1,:))./ gztmp(end,:);
% gztmp(1:end-1,:) = gztmp(1:end-1,:)./repmat(gscale,[nterms-1,1]);
else else
gres = gztmp(end,:) - sum(gztmp(1:end-1,:)); gres = gztmp(end,:) - sum(gztmp(1:end-1,:));
gztmp(1:end-1,:) = gztmp(1:end-1,:) + repmat(gres,[nterms-1 1])/(nterms-1); gztmp(1:end-1,:) = gztmp(1:end-1,:) + repmat(gres,[nterms-1 1])/(nterms-1);