0

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?

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks a lot! Nonetheless, is there still a way to let matlab display the full string instead of doing something like this: test: [1x103 char]?
Check the format command in the docs. format long seems to do the trick.
format long only specifies the accuracy of numerical values. Unfortunately, I couldn't find anything in the docs concerning the format of char arrays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.