I am currently working on an S-Function in Simulink, and I encountered the following error:

3 visualizaciones (últimos 30 días)
Error: Cannot initialize the width of data type work vector 1 of 'untitled/S-Function'. The data type work vector width is set to dynamically sized (-1). Initialize the data type work vector width in mdlInitializeSizes or mdlSetWorkWidths.
I understand that the issue is related to initializing the width of the data type work vector. However, I am unsure about the steps to resolve this error. Could you please provide guidance on how to initialize the data type work vector width in either mdlInitializeSizes or mdlSetWorkWidths?

Respuestas (1)

Ayush Singh
Ayush Singh el 12 de Feb. de 2024
Hi Ahraz
In order to initialize the width of data type work vector using mdlInitializeSizes try adding this code
static void mdlInitializeSizes(SimStruct *S)
{
% Add mdlInitializeSizes code here *
% Register the number of DWork vectors
ssSetNumDWork(S, 1); % This sets the number of DWork vectors to 1
% Set the width of the first (and only) DWork vector
ssSetDWorkWidth(S, 0, 10); % This sets the width of the first DWork vector to 10
}
Here 'S' is SimStruct representing an S-Function block.
For more information on 'mdlInitializeSizes' , 'ssSetNumDWork' and 'ssSetDWorkWidth' refer to following links:
I hope the above information helps!

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by