smbGetPorts

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - SimMechanics
Introduced first in SolidGeometry 3.0, Creation date: 2016-11-10, Last change: 2025-09-14

SimMechanics returns the port of block

Description

It is necessary to name the system

See Also: smbAddFrame , smbAddLine

Example Illustration

 missing image of smbGetPorts(Block)

Syntax

PN=smbGetPorts(Block)

Input Parameter

Block: Name of Block including system; if empty gcb is used

Output Parameter

PN: Cell of Port Strings

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

Output Results

Algorithm Steps

  1. Check if the Block parameter is provided. If not, use gcb to get the current block.
  2. Use smbWhich to resolve the block name.
  3. Find the last occurrence of '/' in the block name to separate the block name from its path.
  4. If the block name is not found, return an empty PN.
  5. Retrieve port connectivity information using get_param with the 'PortConnectivity' parameter.
  6. Initialize a cell array PN to store port information.
  7. Iterate over each port to populate PN with the port type and connected source and destination blocks.
  8. Find all lines in the model using find_system with 'type' set to 'line'.
  9. Retrieve source and destination block handles for each line.
  10. Initialize a cell array LP to store line information.
  11. Iterate over each line to populate LP with line handles and connected source and destination blocks.
  12. 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