Skip to Main Content Skip to Search
Product Documentation

ssGetNumBusElements - Get the number of elements in a bus signal

Syntax

int_T ssGetNumBusElements(SimStruct *S, int_T busTypeID)

Arguments

S

SimStruct that represents an S-Function block

busTypeID

The bus data type identifier that represents the bus signal

Returns

int_T

Description

Use to determine the number of elements in the bus. If one of the elements is also a bus signal, use ssGetNumBusElements recursively to determine the number of elements in the sub-bus signal. The second argument is the identifier that Simulink returns after you register the bus object that represents the bus signal. (To register a bus object, use ssRegisterTypeFromParameter or an equivalent method.)

Bus S-function Usage Guidelines

Use this S-function in simulations. You cannot use this S-function for code generation.

This S-function does not support bus elements that have any of the following characteristics:

To use this S-function and other bus-related S-functions, before you run the simulation, execute the following MATLAB command:

set_param(block_handle, 'EnableBusSupport', 'on')

To automate setting the EnableBusSupport parameter, use one of the following approaches:

Languages

C, C++

Example

static void mdlOutputs(SimStruct *S, int_T tid)
 {
    DTypeId    dType    = ssGetOutputPortDataType(S, 0);
    const void *u       = ssGetInputPortSignal(S, 0);
    int        numElems = ssGetNumBusElements(S, dType);
    int        i;
 
    for(i=0; i<numElems; i++) {
        ….
    }
  }

See Also

ssRegisterTypeFromParameter, ssGetBusElementDataType

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS