How to force a number to be displayed as a string?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Leon
am 29 Jan. 2018
Kommentiert: Leon
am 29 Jan. 2018
I have a list of numbers (6 digits) in the Excel. I read them as strings.
[~, ~, A] = xlsread('filename.xlsx');
The issue is that these number export into my txt file as scientific notation. For example, 123456 would appear as 1.23456 x 10^6. Of course, that doesn't work for a link. How do I force it so that it will be outputed as a normal number?
fprintf(fid, '<td widtd="6%%"><a href="https://www.abcdef.com/%s">%s</a></td>\n', A{i,9}, A{i,9});
0 Kommentare
Akzeptierte Antwort
Benjamin Kraus
am 29 Jan. 2018
Bearbeitet: Benjamin Kraus
am 29 Jan. 2018
Are the numbers stored as numbers or character vectors in MATLAB?
class(A{i,9}) % double or char?
If the answer is double, then you want to use %d in your format string instead of %s.
fprintf(fid, '<td width="6%%"><a href="https://www.abcdef.com/%d">%d</a></td>\n', A{i,9}, A{i,9});
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Standard File Formats finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!