function ApplyInjection(injection, connection, modelPorts) %SET_INJ 设置注入信号 % [conn_type, conn_name] = SelectConnection(injection.tag, connection); if conn_type == 's' || conn_type == 'p' if conn_type == 's' ch = SelectPort(modelPorts.Software, conn_name); elseif conn_type == 'p' ch = SelectPort(modelPorts.Physical, conn_name); end SetPortSignal(ch, ConstructSignal(injection.time, injection.value)); SetPortEnable(ch, injection.enable'); if isfield(injection.option, 'through') SetPortThrough(ch, injection.option.through); end if isfield(injection.option, 'interpolation') SetPortInterpolation(ch, injection.option.interpolation); end end end function Signal = ConstructSignal(time, value) if length(time) == 1 if time == 0 Signal = value; else Signal = [0 0; time value]; end else Signal = [time value]; end end