Doubt in fprintf with double bar
7 次查看(过去 30 天)
显示 更早的评论
How can I print something like this: fprintf(fileID,'>|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|< \r\n'); or like fprintf(fileID,'\\');
I get: Control Character '\/' is not valid. Thanks
0 个评论
采纳的回答
Walter Roberson
2015-10-19
str = '>|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|<';
fprintf(fileID, '%s\r\n', str);
fprintf(fileID, '\\\\')
0 个评论
更多回答(1 个)
Thorsten
2015-10-19
编辑:Thorsten
2015-10-19
\ starts many escape characters, like \n or \r. To print a single \, you have to use the escape character \\.
fprintf(fileID, '>|/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/|< \r\n');
fprintf(fileID, '\\\\')
Note that you can print to fileID 1, which is the standard display. This is quite useful for testing.
fprintf(1, '%%\\')
0 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!