Mathematica Effortlessly Display a Matrix of Numbers in Mathematica | Quick Solution

  • Thread starter Thread starter iva_bg
  • Start date Start date
  • Tags Tags
    Mathematica Table
AI Thread Summary
To display a matrix of numbers in Mathematica with each entry formatted as a percentage, use a custom function. The example provided defines a function, FormatNumber, that appends a "%" sign to each number. By applying this function with the Map command, you can efficiently format the entire matrix without manual input. The final output can be displayed using MatrixForm for better visualization. This method streamlines the process of formatting matrix entries in Mathematica.
iva_bg
Messages
8
Reaction score
0
Hello,

does anyone have an idea how easily to display a matrix of numbers such that each entry, for example 3, is displayed (3%), without having to type it manually, i.e. a command to do it for each entry in my output matrix?

Thanks a lot!
 
Physics news on Phys.org
Maybe something like
Code:
(* I suppose you already have a matrix mat, e.g.: *)
mat = {{1, 2, 3}, {4, 5, 6}, {7, 8,9}}; 

FormatNumber[x_] := ToString[x] <> "%"

Map[FormatNumber, mat, {2}]
% // MatrixForm
 
Thank you, this is fantastic!
 

Similar threads

Replies
5
Views
3K
Replies
2
Views
2K
Replies
1
Views
2K
Replies
2
Views
3K
Replies
6
Views
10K
Replies
2
Views
2K
Replies
3
Views
3K
Back
Top