在 Simulink 中使用 mask 封装参数时,基本工作空间是 Simulink 的默认源。但是,通过使用 simset 函数,可以更改此选项。随后,sim 函数可以与 simset 函数以通使用。
下面是一个示例:
options = simset('SrcWorkspace','current');
sim('modelname',[],options)
该示例将参数来源从基本工作空间变为函数工作空间。
更多帮助请参考您对应版本的 simset 函数的帮助文档。关于如何在函数工作空间创建变量,请参考:
https://www.mathworks.com/matlabcentral/answers/96238-how-do-i-declare-a-variable-in-the-matlab-workspace-from-a-matlab-function