Trimming the Size of a Array of Structures in a MEX file
Afficher commentaires plus anciens
Hi all.
So i'm having a bit of an issue array of structures in a MEX file. I first initialize the array of structures to size that is (most likely) much larger than I need. Then I loop over an operation an unknown number of times, each time filling the next structure in that array of structures. Then, once done, I'd like to trim that array of structures to be the size that it needs to be, and no more.
I initialize the array of structure as follows:
structOut = mxCreateStructMatrix(MAX_FILES, 1, NUMBER_OF_FIELDS, fieldnames);
I have been trimming the size of structOut using the following command:
mxSetM(structOut,cnt);
This does successfully change the size of the variable outputted, but it does not free up the memory associated the orphaned headers (i.e. outStruct(cnt+1:end)).
Effecftively, I'd like to implement something functionally equivalent to the code below, but in mex form:
structOut(cnt+1:end) = [];
What can you recommend to accomplish this, without concurring a large computation time penalty, nor leaking memory.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!