Documentation

ssGetBusElementDimensions

Get the dimensions of a bus element

Syntax

const int_T* ssGetBusElementDimensions(SimStruct* S, int_T busTypeID, int_T elemIdx)

Arguments

S

SimStruct that represents an S-Function block

busTypeID

The bus data type identifier that represents the bus signal

elemIdx

The zero-based bus element index

Returns

const int_T*

Description

Obtain the dimensions (const int_T*) for the bus element that you specify. To iterate over the integer array that ssGetBusElementDimensions returns, use ssGetBusElementNumDimensions.

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++) {
        int_T       numDims   = ssGetBusElementNumDimensions(S, dType, i);
        const int_T *dims     = ssGetBusElementDimensions(S, dType, i);
        int         width     = 1;
        int         j;
        
        /* Compute width of the bus element */
        for(j=0; j<numDims; j++) {
            width *= dims[j];
        }
      }
    }

Introduced in R2010a

Was this topic helpful?