Why writetable() adds ' 'true ' table element as ''table?
12 次查看(过去 30 天)
显示 更早的评论
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:
writetable(transitionsTable,excel_file,'Sheet',1,'Range','C1')
'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 个评论
Walter Roberson
2019-8-2
Excel has strange display rules for text. These days I just assume that excel might be lying about the actual content of text cells.
回答(1 个)
Jeremy Hughes
2019-8-2
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.
try
string(transitionsTable.transition) to see if that's what's happening
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!