www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@conswitch/syncToModel.m
function conModel = syncToModel(conModel,m,OpPoints) %SYNCTOMODEL synchronize constraints to model % conModel = syncToModel(conModel,m) % Copyright 2005-2012 The MathWorks, Inc. if nargin>2 && isequal(size(OpPoints),size(conModel.OpPoints)) conModel.OpPoints = OpPoints; end % make sure boundary model is consistent cif = getInputFactors(conModel); % make sure the ranges are the same otherwise the tolerances will be % awry R = getranges(m); if ~isequal(R,getRange(cif)); cif = setRange(cif,R); conModel = setInputFactors(conModel,cif); conModel = setTolerance(conModel,getTolerance(m)); end % the boundary model operating points ConstraintOpPoints = getSwitchPoints(conModel); Xg = getSwitchPoints(m); [~,~,KeepLast] = mbcUniqueFilters(Xg); if ~isequal(ConstraintOpPoints,double(Xg)) % the operating points can be different if some of the boundary models didn't fit % Note, ismember chooses the last item in ConstraintOpPoints if there are nonunique % points. [ok,loc] =ismember(double(Xg(KeepLast,:)),ConstraintOpPoints,'rows'); conModel = selectModels(conModel,loc(ok)); elseif ~all(KeepLast) conModel = selectModels(conModel,KeepLast); end