Dynamic memory allocation in C++ S_functions
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey there, My question is pretty straightforward: Is it possible/allowed to reallocate Memory in S-functions written in C++. I have an array in my S-Function that buffers data for me and I was wondering if I need to allocate the buffer big enough in my mdlStart function or if I could start off with a small buffer and use realloc() to make it bigger if needed at run-time. While researching this Problem I found some unclear answers to that. Some say, that dynamic allocation is not allowed in Simulink, but I couldn't find any specific Information about this in the documentation. Thanks in advance
2 comentarios
Dhruvesh Patel
el 28 de Jun. de 2017
Editada: Dhruvesh Patel
el 28 de Jun. de 2017
One option could be to use the PWORK Vector . You would need to allocate/reallocate (using malloc/realloc) in your C++ code and give the pointer to this memory to PWORK Vector which will hold on to it throughout the simulation. Refer to (2) of the following answer.
Please provide some example code describing what you intend to archive. It would lead to a more precise answer.
Respuestas (0)
Ver también
Categorías
Más información sobre Configure C/C++ S-Function Features en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!