function newObj = refreshObj(m, obj)
%REFRESHOBJ Update Kronecker Bio objective functions according to a new
%   model
%
%   Whenever either the topolgy or parameters of a model change, the
%   objective function structures should be updated because they may
%   depend on the changes. This function loops over the objective functions
%   in order to accomplish this common task.

% (c) 2010 David R Hagen & Bruce Tidor
% This work is released under the MIT license.

nTop = numel(m);
nCon = size(obj, 1);
nObj = size(obj, 2);
newObj = Gzero([nCon,nObj,nTop]);
for iTop = 1:nTop
    for iCon = 1:nCon
        for iObj = 1:nObj
            newObj(iCon,iObj,iTop) = pastestruct(Gzero(m(iTop)), obj(iCon,iObj,iTop).update(m(iTop)));
        end
    end
end
