Main Content

本页采用了机器翻译。点击此处可查看最新英文版本。

在 Test Sequence 模块中使用外部函数

此示例显示如何从 Test Sequence 模块调用外部定义的函数。提供的函数 Attenuate.m 在 MATLAB® 路径上的脚本中定义,并从测试序列中调用。Attenuate.m 函数是:

function[y] = Attenuate(x)

y = 0.65*x;

end

打开 TestSeqOutputFunctions 模型

model = 'TestSeqOutputFunctions';
open_system(model)

Test Sequence Output Functions model

打开 Test Sequence 模块

在模型中,双击 Test Sequence 模块,调用扩展函数。Test Sequence 模块中的 ReducedSine 步骤使用外部函数 Attenuate 来降低信号 sg 的幅度。

仿真模型

仿真模型并在 Scope2 模块中查看输出信号 sg 和衰减信号 asg

sim(model)
open_system([model '/Scope2'])

Plots of sine and attenuate sine signals

close_system(model,0)