From: Eduardo M. A. M.Mendes on
Hello there

I am new to Mathematica. In one of my attempts to understand how it works,
I tried the following example

A={{1,2,3},{4,5,6},{7,8,9}} //MatrixForm

The result seems to be a matrix 3x3 but when I try A[[1][1]], the whole
first line shows up instead of just one element. If I don't use MatrixForm,
it works fine. How can I see a matrix in nice format without wrecking
everything?

Many thanks

Ed


From: David Park on
I would usually write that as:

(amat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}) // MatrixForm

amat[[1]][[1]]

amat[[1, 1]]


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/


From: Eduardo M. A. M.Mendes [mailto:emammendes(a)gmail.com]

Hello there

I am new to Mathematica. In one of my attempts to understand how it works,
I tried the following example

A={{1,2,3},{4,5,6},{7,8,9}} //MatrixForm

The result seems to be a matrix 3x3 but when I try A[[1][1]], the whole
first line shows up instead of just one element. If I don't use MatrixForm,
it works fine. How can I see a matrix in nice format without wrecking
everything?

Many thanks

Ed




From: Peter Pein on
Am Wed, 4 Aug 2010 09:51:07 +0000 (UTC)
schrieb "Eduardo M. A. M.Mendes" <emammendes(a)gmail.com>:

> Hello there
>
> I am new to Mathematica. In one of my attempts to understand how it
> works, I tried the following example
>
> A={{1,2,3},{4,5,6},{7,8,9}} //MatrixForm
>
> The result seems to be a matrix 3x3 but when I try A[[1][1]], the
> whole first line shows up instead of just one element. If I don't
> use MatrixForm, it works fine. How can I see a matrix in nice format
> without wrecking everything?
>
> Many thanks
>
> Ed
>
>

Do not assign MatrixForm[{{<matrix>}}] to a but {{<matrix>}} and throw
MatrixForm onto A:

In[11]:= (A={{1,2,3},{4,5,6},{7,8,9}})//MatrixForm
Out[11]//MatrixForm=
(
1 2 3
4 5 6
7 8 9
)
In[12]:= A[[1,1]] (* A[[1][1]] is wrong *)
Out[12]= 1

hth,
Peter

From: Bob Hanlon on

Use parentheses to exclude MatrixForm from the definition of A

(A = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}) // MatrixForm

A[[1, 1]]

1

A[[1]][[1]]

1


Bob Hanlon

---- "Eduardo M. A. M.Mendes" <emammendes(a)gmail.com> wrote:

=============
Hello there

I am new to Mathematica. In one of my attempts to understand how it works,
I tried the following example

A={{1,2,3},{4,5,6},{7,8,9}} //MatrixForm

The result seems to be a matrix 3x3 but when I try A[[1][1]], the whole
first line shows up instead of just one element. If I don't use MatrixForm,
it works fine. How can I see a matrix in nice format without wrecking
everything?

Many thanks

Ed


From: Bill Rowe on
On 8/4/10 at 5:50 AM, emammendes(a)gmail.com (Eduardo M. A. M.Mendes)
wrote:

>I am new to Mathematica. In one of my attempts to understand how it
>works, I tried the following example

>A={{1,2,3},{4,5,6},{7,8,9}} //MatrixForm

>The result seems to be a matrix 3x3 but when I try A[[1][1]], the
>whole first line shows up instead of just one element. If I don't
>use MatrixForm, it works fine. How can I see a matrix in nice
>format without wrecking everything?

My recommendation is

Go to preferences. Select the evaluation tab. Then, use the menu
to set the format for new output cells to be TraditionalForm
from the menu. This will cause the display of all matrices to
have a pretty form that you like without the need for MatrixForm.

The problem with MatrixForm is that it does two things. It
causes the display to be what you want. But it also adds a
wrapper to the matrix being displayed. That is,

In[1]:= a = RandomInteger[10, {2, 2}]

Out[1]= {{5, 4}, {2, 5}}

In[2]:= MatrixQ[a]

Out[2]= True

In[3]:= b = MatrixForm[a];
MatrixQ[b]

Out[4]= False

MatrixForm will not change the way arguments supplied to it
evaluate. This is what is meant when the documentation says
MatrixForm does not effect evaluation. But the output of
MatrixForm is not a matrix and cannot be used as a matrix directly.