Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nicely print out a matrix in mathematica

I have a list of lists (matrix) in mathematica. I want to print it out nicely, with the max in every row in bold. How to do this?

Or maybe even further, with a circle outside such max, is this possible?

like image 382
Qiang Li Avatar asked Feb 11 '11 05:02

Qiang Li


People also ask

How do you write a matrix in Mathematica?

Select Insert ▶ Table/Matrix ▶ New: In the window that appears, select Matrix (List of lists), enter the number of rows and columns for your matrix, and click OK: Your matrix is inserted into your notebook: Copy to clipboard.

How do you write matrices in Wolfram Alpha?

Writing Matrices in Mathematica (Wolfram Alpha)Matrices are written with braces, {}. Within the braces we list the rows with more braces. So a matrix with four rows is written {{Row1},{Row2},{Row3},{Row4}}. Each row is separated by a comma and each entry is separated by a comma.


1 Answers

You can use MatrixForm to print out matrices nicely:

data = RandomInteger[100, {5, 5}];

data // MatrixForm

yields

MatrixForm image

You can draw a circle around the maximum in each row as follows:

Map[# /. m : Max[#] :> Framed[m, RoundingRadius -> 1000]  &, data] //
  MatrixForm

yielding

matrix with circles

RoundingRadius -> 1000 uses a ridiculously large parameter to get circles. You may need to adjust the constant depending upon the scale of your display.

You can change Framed[m...] with Style[m, Bold] if you prefer bolding.

like image 91
WReach Avatar answered Oct 14 '22 09:10

WReach