Why do I receive an error when I use '\' as the delimiter in the TEXTSCAN command?
4 次查看(过去 30 天)
显示 更早的评论
When I execute the code:
p=cd;
textscan(p,'%s','delimiter','\');
I receive the error:
??? Error using ==> textscan
Delimiter has incorrect \ constant.
采纳的回答
MathWorks Support Team
2010-1-7
This change has been incorporated into the documentation in Release 2009b (R2009b). For previous releases, read below for any additional information:
This is an expected behavior in MATLAB. The character '\' is a MATLAB operator and is hence interpreted. In order to pass in the '\' character in its un-interpreted form to the TEXTSCAN command, it needs to be preceeded by the escape character '\'. Therefore, to use '\' as the delimiter in the TEXTSCAN command, execute:
textscan(p,'%s','delimiter','\\');
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!