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

采纳的回答

Walter Roberson
Walter Roberson 2015-10-19
str = '>|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|<';
fprintf(fileID, '%s\r\n', str);
fprintf(fileID, '\\\\')

更多回答(1 个)

Thorsten
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, '%%\\')

类别

Help CenterFile Exchange 中查找有关 App Building 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by