How would one enumerate the inport and outport handles of a block problematically in Simulink? So far I have tried using the following, where 'sfunc' has already been set to the block handle:
inports = get_param(sfunc, 'Inport')
outports = get_param(sfunc, 'Outport')
Which returns a two dimensional array where its size is equal to the number of specified ports. But when I run the following (with either 'inports' or 'outports')
get_param(inports, 'Handle')
It states that the array must be a vector. Am I going about this the right way? And if so, how do I convert an array into a ve开发者_JAVA技巧ctor? Essentially what I am trying to do is get the handle of the lines connected to the block so I can link them up later after replacing the current block with a new one. Any help on this would be appreciated.
Try using the parameter PortHandles, this will give you a structure with fields like Inport, Outport, EnablePort, etc. The fields Inport and Outport will be an array of handles, the size of the number of ports.
>> ph = get_param(sfunc, 'PortHandles')
>> inportHandles = ph.Inport;
% Get the 2nd input port handle
>> input_2 = inportHandles(2);
>> line = get_param(input_2, 'Line');
精彩评论