Message Boards Message Boards

0
|
4191 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Format output of a matrix?

Posted 5 years ago

I am new to Mathematica and I am stuck with this!

I wrote a code that outputs a matrix and its heading, separately. I want to combine these outputs such that it is easy to be understood. (I.e. I want to re-shape this matrix into a grid/table that has labels to easily understand what does each column refer to).

In the attached file, I want to name the first column in the matrix {1,2} and the second column in the matrix {1,3} and so on.

Attachments:
POSTED BY: Nehal Elshaboury
3 Replies

Thank you very much. The code worked for me.

POSTED BY: Nehal Elshaboury
Posted 5 years ago

Nehal,

Do you mean this?

Grid[colmat // Prepend[paths], Frame -> All, ItemSize -> All, 
 Background -> {Automatic, {1 -> Yellow}}, 
 ItemStyle -> {Automatic, {1 -> {FontSize -> 14, Bold}}}]

Part of the resulting very large grid

enter image description here

POSTED BY: Rohit Namjoshi

A first try (if I understand correctly what you want to do):

Write

colmat = Transpose[Apply[Plus, Subsets[Transpose[pathmatrix], {2}], {1}]];
% // MatrixForm

instead of your statement in your notebook and then at the end

TableForm[colmat, TableAlignments -> Center, TableHeadings -> {None, paths}]
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract