Writing ~ using fprintf

2 views (last 30 days)
David Corella López
David Corella López on 13 Dec 2020
Hello to everyone.
The point of this question is how to write the character ~ when using fprintf.
When I write it, I get the following message:
Warning: Escaped character '\~' is not valid.
Moreover, I'm wondering how to add a text before a mathematical expression, i.e.:
fprintf(f,'\~y\~-\~w %.6E & %.6E & %.6E & %.6E\\\\',A(1, :));
What sould I do in order to write that?
Thank you very much.

Accepted Answer

Jan
Jan on 13 Dec 2020
The tilde can be printed directly without escaping:
fprintf('This is a tile: ~\n')
And what is the problem with adding text?
fprintf(f,'~y~-~w %.6E & %.6E & %.6E & %.6E\\\\', A(1, :));
  2 Comments
David Corella López
David Corella López on 13 Dec 2020
Hello.
Firstly, thanks for your answer!
I didn't explain myself well enough.
Now, I've realized the problem is not really with the tilde but with the bar \. I need to print it, too, in order to write it in LaTeX.
David Corella López
David Corella López on 13 Dec 2020
Ok. I've already solved it. Thanks!

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!