Re: Matrix Output

• To: mathgroup at smc.vnet.net
• Subject: [mg71022] Re: Matrix Output
• From: Bill Rowe <readnewsciv at sbcglobal.net>
• Date: Sat, 4 Nov 2006 23:07:21 -0500 (EST)

```On 11/4/06 at 4:08 AM, xmzwl at yahoo.com (Liz) wrote:

>Hello, how to output the result "E" as matrix? Is there better way
>to get the results and output the results into matrix?

>A=[1 4];
>B=[2 5];
>E=zeros(4,2);
> for m=1:length(A)
>  for n=1:length(B)
>   E=[A(m) B(n)]
>  end
> end

If I understand what you want correctly, then the matrix can be
created by

In[5]:=
b=Transpose@{Range@4,Range[2,5]}

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

or

In[6]:=
b=Partition[Range@5,2,1]

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

Note, it is not a good idea to use uppercase letters as variable
names in Mathematica as this leads to conflicts with built in
definitions. Specifically, E is already defined as 2.718... and
cannot be used to store a matrix
--
To reply via email subtract one hundred and four

```

• Prev by Date: Re: Tricky visualization of maximization problem
• Next by Date: Re: Tricky visualization of maximization problem
• Previous by thread: Re: Matrix Output
• Next by thread: capturing formatting