Doubt in fprintf with double bar
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How can I print something like this: fprintf(fileID,'>|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|< \r\n'); or like fprintf(fileID,'\\');
I get: Control Character '\/' is not valid. Thanks
0 commentaires
Réponse acceptée
Walter Roberson
le 19 Oct 2015
str = '>|/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|<';
fprintf(fileID, '%s\r\n', str);
fprintf(fileID, '\\\\')
0 commentaires
Plus de réponses (1)
Thorsten
le 19 Oct 2015
Modifié(e) : Thorsten
le 19 Oct 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, '%%\\')
0 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!