How can I dynamically grow the work vector in my level 2 MATLAB file S-function in Simulink 6.5 (R2006b)?

1 view (last 30 days)
I want to implement a similar functionality as the Transport Delay block has in my level 2 MATLAB file S-function. So I need a buffer, but as I do not know the sample time for the model I do not know how to size my buffer. The Transport Delay block automatically increases the buffer size if needed, but the DWork vector dimensions are set once and are fixed.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 16 Jan 2010
The ability to change the dimension of the DWork vector for a level 2 MATLAB file S-function is not available in Simulink 6.5 (R2006b).
To work around this issue you can use one of the following approaches:
a. Make a worst-case estimation of how large your buffer needs to be and use this data for the DWork vector's dimension.
b. Use a C-MEX S-function instead of the MATLAB file S-function. In C-MEX you could use a PWork vector to keep a pointer to your buffer. In the beginning of your simulation you would allocate an initial buffer size. If your buffer is going to overflow you could re-allocate (realloc) the memory needed for the buffer.

More Answers (0)

Categories

Find more on Block and Blockset Authoring in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2006b

Community Treasure Hunt

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

Start Hunting!