www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@mbcinputfactor/SimSetInvCode.m
function mF=SimSetInvCode(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 = zeros(1,length(obj)); Offset = 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 = 'square'; case 'log10(x)' op = '10^u'; case 'x.^2' op = 'sqrt'; case 'log(x)' op = 'exp'; end set_param(mF(i),'operator',op); end Gain(i) = 1/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);