2
做为什么strcat(mystring)与mystring不同?
[~, currenthost] = system('hostname');
table({currenthost}, 'VariableNames', {'host'})
给
ans =
host
__________
[1x9 char]
,而这样做
[~, currenthost] = system('hostname');
table({strcat(currenthost)}, 'VariableNames', {'host'})
给
ans =
host
_________
'my-hostt'
为什么?
是的,就是这样。尽管如此,人们应该注意到Matlab命令行中的尾随空格?! – jakub
@jakub耶...你只是有运气不好,你的主机名是8个字符。如果它是9,你会意识到1x9和1x10字符数组! –
@jakub看看[这里](http://stackoverflow.com/q/37998621/3372061)的一个窍门是在使用'strcat'时保留空格。 –