text substitute for MAT files

Hello all:
I am debugging a large Matlab application from 2014 (tens of thousands of lines) and the previous developer used .MAT files to store data and also to pass it here and there. I think maybe he didn't understand how to pass data to callbacks, but that's neither here nor there. Somewhere the data is getting corrupted, and by a certain point in the application it is reliably wrong.
I thought of changing all the save() and load() functions to use the -ascii version to see if I could figure out when and where it goes wrong. Unfortunately, -ascii does not seem to save structs. Is anyone aware of a way to store and restore complicated (but not particularly large) Matlab variables as text?
Thank you,
-Tom

6 comentarios

dpb
dpb el 15 de Feb. de 2019
Is this "point in the application" one in code location or in time of execution as in an iteration process?
If the former could you not insert a debug break at some point prior to that and by rough bisection be able to isolate where something seems to have gone south?
Looking at data in files even as ascii seems the hard way to debug; reminiscent of FORTRAN 77 days before source debuggers...
Tom Sgouros
Tom Sgouros el 16 de Feb. de 2019
Thanks, yes, it seems painful. It's a user-driven application with lots of branching and five or six different data values in a few different MAT files that wind up incorrect by the time the user gets to the ninth or tenth step. Really, a nightmare. Still just trying to make sense of it and hoping that making the files more transparent can help me make sense, if not of it all, then at least some piece of it. But maybe the ASCII facility I imagine does not exist?
Walter Roberson
Walter Roberson el 16 de Feb. de 2019
Export to readable ASCII would be easier than import of ASCII.
Because you can have nested structures, and multidimensonial arrays, and objects with properties, it is a lot easier to create text that humans do not mind reading through, than it is to create text that MATLAB can parse to exactly recreate objects.
Now, you could use JSONlab from the file exchange to import and export structured data, but if your primary purpose is debugging then you would have to decide whether JSON is readable enough for your purpose.
Perhaps you can use conditional breakpoints to detect the characteristics of corruption. It might be after the fact, but by examining the state you might be able to work backwards.
dpb
dpb el 16 de Feb. de 2019
If you're still on this same path, you might consider struct2table and then writetable to do the one-way translation; I don't know that it is always reproducible to the identical structure via table2struct or not.
Tom Sgouros
Tom Sgouros el 17 de Feb. de 2019
JSON would be perfect. Thank you!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Variables en Centro de ayuda y File Exchange.

Productos

Versión

R2018b

Preguntada:

el 15 de Feb. de 2019

Comentada:

el 17 de Feb. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by