How can I print something like this: fprintf(fileID,'>|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|< \r\n'); or like fprintf(fileID,'\\');
I get: Control Character '\/' is not valid. Thanks

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Okt. 2015

1 Stimme

str = '>|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|<';
fprintf(fileID, '%s\r\n', str);
fprintf(fileID, '\\\\')

Weitere Antworten (1)

Thorsten
Thorsten am 19 Okt. 2015
Bearbeitet: Thorsten am 19 Okt. 2015

2 Stimmen

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

Kategorien

Produkte

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by