How do I add superscript numbers to a CSV-File with fprintf?

4 views (last 30 days)
Hello,
I want to include a superscript number into my header of a generated csv file. Code is the following:
header = ['Eindruckfläche [µm^2}]', "Eindruckdurchmesser [µm]", "Gemessene Tiefe [µm]","Höhe PileUp [µm]", "Theoretische Tiefe aus Kugeldurchmesser [µm]"];
L = [P_area, P_diameter, P_depth, pile_up_height, depthConv];
ergName = cat(2, filename, 'Erg', '.csv');
result = fopen(ergName, 'w');
for c = 1:4
fprintf(result,'%s', header(c));
fprintf(result,'%c', ';');
end
fprintf(result,'%s\n', header(5));
for c = 1:4
fprintf(result,'%.2f', L(c));
fprintf(result,'%c', ';');
end
fprintf(result,'%0.2f', L(5));
fclose('all');
The number that should be superscript is the µm^2 in the first row. I already tried following things:
header = ['Eindruckfläche [µm<sup>2</sup>]', "Eindruckdurchmesser [µm]", "Gemessene Tiefe [µm]","Höhe PileUp [µm]", "Theoretische Tiefe aus Kugeldurchmesser [µm]"];
header = ['Eindruckfläche [µm^{2}]', "Eindruckdurchmesser [µm]", "Gemessene Tiefe [µm]","Höhe PileUp [µm]", "Theoretische Tiefe aus Kugeldurchmesser [µm]"];
header = ['Eindruckfläche [µmbase^{2}]', "Eindruckdurchmesser [µm]", "Gemessene Tiefe [µm]","Höhe PileUp [µm]", "Theoretische Tiefe aus Kugeldurchmesser [µm]"];
  1 Comment
dpb
dpb on 13 Sep 2018

Isn't possible; fprintf doesn't know anything about TeX or other text formatting mechanisms. All it does (and all it can do) is to echo the bytes from internal storage form to the disk file as presented and processed by the C language compatible formatting instructions.

You could store the string to have a text label be displayed using that string that would be interpreted by handle graphics for example, but the formatting itself would not be in the file; simply the instruction for how to generate the appearance later.

This basically is the way any presentation works; it's the display code for html or pdf or whatever format is used that takes care of the actual appearance but what is stored in the file is simply instructions, not the actual result.

Sign in to comment.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 13 Sep 2018
CSV file can not contain format so you can't achieve superscript in CSV file.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!