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

7 ビュー (過去 30 日間)
Tim Wünderlich
Tim Wünderlich 2018 年 9 月 13 日
コメント済み: dpb 2018 年 9 月 13 日
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 件のコメント
dpb
dpb 2018 年 9 月 13 日

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.

サインインしてコメントする。

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2018 年 9 月 13 日
CSV file can not contain format so you can't achieve superscript in CSV file.

カテゴリ

Help Center および File ExchangeMATLAB Compiler についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by