mxAddField/mxGetField with unicode name
Afficher commentaires plus anciens
I am trying to write code that allows for arbitrary field names in Matlab structures. I thought I had a decent solution, based on using mex to set invalid fields. To make the interface the same as a normal structure, I overloaded subsref in an object so that the mex call is made transparently. Retrieval of invalid fields is possible using dynamic structure indexing (e.g. value = s.("invalid name")).
Everything seemed to be working well, then I realized that there is no public mex interface to set fieldnames using the 2-byte per character string format that Matlab uses. This means I am unable to set a field with a non-ASCII fieldname. Instead it seems like struct fields may instead be stored as c-style strings in ASCII format. Is this true? Is it possible to work with structures using 2-byte wide characters. An alternative is to wrap everything in the object or to use something like containers.Map, but both are much slower to use than structures, and I'd like to be able to fall back to structures (from objects) in certain use cases when the setting of additional invalid fields using the "set field" mex function isn't necessary. Any other suggestions?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Structures dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!