Transfer from Decimal to Percentage?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Xiao Tang
am 25 Jun. 2012
Kommentiert: geopap
am 14 Sep. 2016
Hi guys,
I have a Matrix A =
[1 2 3
4 5 6
7 8 9]
How I can get Matrix B =
[100% 200% 300%
400% 500% 600%
700% 800% 900%]?
Sprintf might work but I don't know how to use it. Thanks in advance.
2 Kommentare
Walter Roberson
am 25 Jun. 2012
You cannot get it as a numeric matrix, as numeric matrices cannot contain '%' characters.
Akzeptierte Antwort
Walter Roberson
am 25 Jun. 2012
thisfmt = [ repmat(' %.3f%%', 1, size(A,2)) '\n'];
B = sprintf( thisfmt, A.' );
B(1) = '[';
B(end) = ']';
This creates the output as a single string.
8 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!