Search code examples
matlabencode

Stringify structure in MATLAB


I want to be able to output a stringifid version of a structure in Matlab. I already found http://www.mathworks.com/matlabcentral/fileexchange/15017-struct2str but this outputs boolVariable: [1x1 logical] for logical variables.

The builtin disp function displays logical variables with a one or zero but cuts off strings, e.g. test: [1x103 char].

How can I both output a full string and a readable boolean representation?


Solution

  • Maybe JSON works for you. There's no builtin solution for that, but google e.g. yields this package:

    http://www.cs.sunysb.edu/~kyamagu/software/json/

    It should serialize strings fully and make logicals either 0/1 or true/false, the website doesn 't tell and I didn't test it.