PName=smbGetPortofFrame(FName)
FName : | Frame Name in a Subsystem |
PName : | Name of Port in the Current System |
Show the Port Name of the Origin Frame
smbNewSystem ('untitled');
smbGetPortofFrame('WORLD.ORIGIN')
This function, smbGetPortofFrame
, is designed to retrieve the port name associated with a given frame name within a Simulink subsystem. The function is part of the SimMechanics library and was created by Tim Lueth in November 2016.
smbGetAllPorts(gcs)
, which retrieves all ports in the current system. The function returns three outputs, but only the third output, c
, is used in this function.c
is expected to be a cell array where each row contains information about a port. The third column of each row contains the frame name associated with that port.PName
is initialized to store the port name if a match is found.for
loop iterates over each row of c
:FName
is a substring of the third column of that row using strfind
.PName
is set to the value in the first column of that row, which is the port name.PName
is not empty, the function removes the current system's name from PName
using strrep
. This is done to ensure that the port name is relative to the current system.PName
as the output.To demonstrate the function, the example provided shows how to retrieve the port name for the frame 'WORLD.ORIGIN' in a system named 'test_smb_lib':
smbNewSystem('test_smb_lib'); smbGetPortofFrame('WORLD.ORIGIN');Algorithm explaination created using ChatGPT on 2025-08-18 22:36. (Please note: No guarantee for the correctness of this explanation)