How do you convert numbers to percentages?
12 views (last 30 days)
Show older comments
transMatrix = [.02 .01 0 0 .06 -.08; .03 .12 .12 0 .17 -.06; .025 .07 0 .0002 .07 -.03; 0 0 .0002 0 .05 -.02] I would like to change these numbers to percentages.
2 Comments
Walter Roberson
on 4 Sep 2018
Percentage out of the row total? Percentage out of the column total? Percentage out of the entire matrix total?
Accepted Answer
Stephen23
on 4 Sep 2018
Edited: Stephen23
on 4 Sep 2018
>> P = 100 * transMatrix
P =
2.00000 1.00000 0.00000 0.00000 6.00000 -8.00000
3.00000 12.00000 12.00000 0.00000 17.00000 -6.00000
2.50000 7.00000 0.00000 0.02000 7.00000 -3.00000
0.00000 0.00000 0.02000 0.00000 5.00000 -2.00000
You can easily print them with a % symbol:
>> F = sprintf('%s\n',repmat('%8g%%',1,6));
>> fprintf(F,P.')
2% 1% 0% 0% 6% -8%
3% 12% 12% 0% 17% -6%
2.5% 7% 0% 0.02% 7% -3%
0% 0% 0.02% 0% 5% -2%
0 Comments
More Answers (0)
See Also
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!