This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Get the address of a contiguous signal entering an input port


const void *ssGetInputPortSignal(SimStruct *S, int_T inputPortIdx)



SimStruct representing an S-Function block.


Index of the port whose address is required.


A pointer (void *) to the input port specified by the index inputPortIdx.


Use to get the address of a contiguous signal entering an input port. Your S-function should use this macro only if mdlInitializeSizes has specified that the elements of the input signal be contiguous, using ssSetInputPortRequiredContiguous. For noncontiguous input, use the ssGetInputPortSignalPtrs function.

    Note   If you have specified that the input ports are reusable using ssSetInputPortOptimOpts, then you cannot use ssGetInputPortSignal anywhere except in mdlOutputs. For example, if the inputs have been specified as reusable with the SS_REUSABLE_AND_LOCAL flag, the mdlUpdate routine errors out because it tries to access input memory that is unavailable.

    Note   The ssGetInputPortSignal macro becomes a function when you compile your S-function in debug mode (mex -g).


C, C++


The following code demonstrates the use of ssGetInputPortSignal.

nInputPorts = ssGetNumInputPorts(S);
	for (i = 0; i < nInputPorts; i++) {
		int_T nu = ssGetInputPortWidth(S,i);

	if ( ssGetInputPortRequiredContiguous(S,i) ) {
		const void *u = ssGetInputPortSignal(S,i);
		UseInputVectorInSomeFunction(u, nu);

		} else {

		InputPtrsType u  = ssGetInputPortSignalPtrs(S,i);
			for (j = 0; j < nu; j++) {

If you know that the inputs are always real_T signals, the ssGetInputPortSignal line in the above code snippet would be

const real_T *u = ssGetInputPortRealSignal(S,i);

Introduced before R2006a

Was this topic helpful?