Syntax
PN=smbGetPorts(Block)
Input Parameter
Block : | | Name of Block including system; if empty gcb is used |
Output Parameter
Examples
smbGetPorts ('test_fourbar/Frame 3')
Copyright 2016-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, smbGetPorts
, is designed to retrieve port information from a specified SimMechanics block within a Simulink model. Below is a detailed explanation of the algorithm and its parameters.
Input Parameters
- Block: The name of the block, including the system path. If this parameter is empty, the function uses the current block (
gcb
).
Output Results
- PN: A cell array containing port strings.
- LP: A cell array containing line port information.
- oi: Indices of output lines connected to the block.
- ii: Indices of input lines connected to the block.
Algorithm Steps
- Check if the
Block
parameter is provided. If not, use gcb
to get the current block.
- Use
smbWhich
to resolve the block name.
- Find the last occurrence of '/' in the block name to separate the block name from its path.
- If the block name is not found, return an empty
PN
.
- Retrieve port connectivity information using
get_param
with the 'PortConnectivity' parameter.
- Initialize a cell array
PN
to store port information.
- Iterate over each port to populate
PN
with the port type and connected source and destination blocks.
- Find all lines in the model using
find_system
with 'type' set to 'line'.
- Retrieve source and destination block handles for each line.
- Initialize a cell array
LP
to store line information.
- Iterate over each line to populate
LP
with line handles and connected source and destination blocks.
- Find indices of lines where the block is the source (
oi
) and where the block is the destination (ii
).
Algorithm explaination created using ChatGPT on 2025-08-19 07:30. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21