Message Boards Message Boards

GROUPS:

Formatting Output of Matrix

Posted 10 days ago
214 Views
|
3 Replies
|
0 Total Likes
|

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:
3 Replies

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 10 days 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

Thank you very much. The code worked for me.

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