Doubt in fprintf with double bar

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

 Respuesta aceptada

Walter Roberson
Walter Roberson el 19 de Oct. de 2015
str = '>|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|<';
fprintf(fileID, '%s\r\n', str);
fprintf(fileID, '\\\\')

Más respuestas (1)

Thorsten
Thorsten el 19 de Oct. de 2015
Editada: Thorsten el 19 de Oct. de 2015
\ 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, '%%\\')

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 19 de Oct. de 2015

Editada:

el 19 de Oct. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by