www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/xregModelListWrapper.m
classdef xregModelListWrapper < handle & matlab.mixin.Copyable %xregModelListWrapper wrapper class for sharing models in xregmodswitch objects % % See also xregmodswitch % Copyright 2014 The MathWorks, Inc. and Ford Global Technologies, Inc. properties Models = {}; end methods function M = xregModelListWrapper(Models) for i=1:length(Models) Models{i}= compress(Models{i}); end M.Models = Models; end function y = EvalModel(M,Index,x,varargin) y = EvalModel(M.Models{Index},x,varargin{:}); end function p = pev(M,Index,x,varargin) p = pev(M.Models{Index},x,varargin{:}); end function c = ceval(M,Index,x,varargin) c = ceval(M.Models{Index},x,varargin{:}); end function OK = checkmodel(m) %CHECKMODEL check for valid model objects % OK = checkmodel(m) OK=1; for i=1:length(m.Models) OK = OK && checkmodel(m.Models{i}); end end function m = augment(m1,m2) m = xregModelListWrapper([m1.ModelList(:);m2.ModelList(:)]); end function ok = pevSupported(m) %PEVSUPPORTED Check whether PEV simulink export is supported % % PEVSUPPORTED(M) returns true if the model supports PEV simulink export. % For switching models, this is only true if every contained model % supports PEV evaluation. ok = true; for i=1:length(m.Models) ok = ok && pevSupported(m.Models{i}) && ~isa(m.Models{i},'localmod'); end end function ok = pevcheck(m) %PEVCHECK Check whether PEV evaluation is supported % PEVCHECK(M) returns true if the model supports PEV evaluation. For % switching models, this is only true if every contained model supports % PEV evaluation. ok = true; for i=1:length(m.Models) ok = ok && pevcheck(m.Models{i}); end end function d = str_func(m) d= cell(length(m.Models),1); for i=1:length(m.Models) d{i} = str_func(m.Models{i}); end end function OK = concheck(m) OK = true; for i=1:length(m.Models) % has a boundary model if all models have boundary % models OK = OK && concheck(m.Models{i}); end end function m = clearConstraints(m) %clearConstraints clear constraints for model for i=1:length(m.Models) if isa(m.Models{i},'xregexportmodel') && concheck(m.Models{i}) % remove constraint from component model m.Models{i} = setconstraints(m.Models{i},[]); end end end function removePEV(m) for i=1:length(m.Models) m.Models{i}= removePEV(m.Models{i}); end end function ok = canExportToSimulink(m) ok = true; for i=1:length(m.Models) ok = ok && canExportToSimulink(m.Models{i}); end end function R = var(m) R = cell(1,length(m.Models)); for i=1:length(R) R{i} = full(var(m.Models{i})); end end end end