www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@mbcinputfactor/SimSetCode.m
function mF=SimSetCode(obj,mF,Mid,Gb) %SIMSETCODE builds SIMULINK block for coding % % This function will set up the appropriate coding info g % in the math function block % Copyright 2007 The MathWorks, Inc. Gain = ones(1,length(obj)); Offset = zeros(size(Gain)); for i=1:length(obj); c = obj(i); g = c.NonlinearTransform; if ~isempty(g) op = char(g); switch op case '1./x' op='reciprocal'; case 'sqrt(x)' op= 'sqrt'; case 'log10(x)' op= 'log10'; case 'x.^2' op= 'square'; case 'log(x)' op= 'log'; end set_param(mF(i),'operator',op); end Gain(i) = c.Scale; Offset(i) = c.Offset; end midValue=['[',sprintf('%.15g ',Offset),']']; gainValue= ['[',sprintf('%.15g ',Gain),']']; set_param(Mid,'value',midValue); set_param(Gb,'gain',gainValue);