如何获取 MATLAB 函数端口的名称?

How to get name of MATLAB function ports?

如何获取 MATLAB 函数块端口的名称?

我已经试过了:

Port = get_param(SourceBlock, 'PortHandles'); %SourceBlock is the Matlab Function block
Port_Name = get_param(Port.Inport, 'Name');

但它 returns 我是一个空字符。

好的,我终于找到了如何做到这一点。要检索 Matlab 函数端口,您必须使用 Stateflow API。我使用此代码:

rt = sfroot; % stateflow root
A = rt.find('-isa','Stateflow.EMChart', 'Path', SourceBlockPath); % Find the MATLAB Function block (without Path property, it display all Matlab Function blocks)
B = A.outputs(1).Name; % Get the name of the 1st outport