Why do I receive an error when I use '\' as the delimiter in the TEXTSCAN command?
4 views (last 30 days)
Show older comments
When I execute the code:
p=cd;
textscan(p,'%s','delimiter','\');
I receive the error:
??? Error using ==> textscan
Delimiter has incorrect \ constant.
Accepted Answer
MathWorks Support Team
on 7 Jan 2010
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 Comments
More Answers (0)
See Also
Categories
Find more on Text Files in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!