Why writetable() adds ' 'true ' table element as ''table?

1 view (last 30 days)
Chen David Gongwei
Chen David Gongwei on 2 Aug 2019
Answered: Jeremy Hughes on 2 Aug 2019
Here is how my MATLAB table transitionsTable looks like:
I added a single quote before true and false so that Excel won't interpret them as special words.
But when I do:
'true and 'false show up in Excel cells like this:
It looks fine, but those single quotes aren't suppose to show. When I double-click on one of them, it becomes:
  1 Comment
Walter Roberson
Walter Roberson on 2 Aug 2019
Excel has strange display rules for text. These days I just assume that excel might be lying about the actual content of text cells.

Sign in to comment.

Answers (1)

Jeremy Hughes
Jeremy Hughes on 2 Aug 2019
I think this is a case where using strings would make things more clear.
In MATLAB, if I create a char vector and put a single-quote in it, that looks like
c = '...''...'
If I do this with a string, I can avoid the escaping.
s = "...'..."
It may be the case that the char vectors in your data have two single-quotes, which display as one in MATLAB.
string(transitionsTable.transition) to see if that's what's happening


Community Treasure Hunt

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

Start Hunting!

Translated by