printing char(177) to text file
Show older comments
I want to put +/- char(177) between the numbers x & y and save the output as text file.
x = [4 5 6];
y = x*0.8;
Using sprintf, I get the output on the command window:
sprintf(['%2.0f ' char(177) ' %1.2f\n'], [x;y])
But when I am using
fid = fopen('untitled.txt', 'w');
fprintf(fid, ['%2.0f' char(177) '%1.2f\n'], [x;y]);
fclose(fid);
I don't get +/- between the numbers.
5 Comments
Niklas Nylén
on 28 Mar 2014
Edited: Niklas Nylén
on 28 Mar 2014
Your code works for me, Windows 7 (32-bit), R2011b , this is what the text file looks like after I run it:
4±3.20
5±4.00
6±4.80
Have you tried opening the txt file in several text editor programs? Maybe the one you're using does not handle the ± character correctly.
Patrik Ek
on 28 Mar 2014
Worked excelent for me win7 64-bit. What operating system do you use?
Rakesh
on 28 Mar 2014
Niklas Nylén
on 28 Mar 2014
Can you see the ± symbol if you open the txt file in the Matlab editor?
Rakesh
on 31 Mar 2014
Answers (0)
Categories
Find more on Adding custom doc in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!