       Re: Exporting a vector

• To: mathgroup at smc.vnet.net
• Subject: [mg108890] Re: Exporting a vector
• From: Bill Rowe <readnews at sbcglobal.net>
• Date: Tue, 6 Apr 2010 07:24:03 -0400 (EDT)

```On 4/5/10 at 8:02 AM, sagittarius5962 at gmail.com (nt) wrote:

>I want to export a vector from a loop statement with two counting
>variables, i,j. as an example:

>w0=1;dk=1; eq= a function of w and k; Do[{w[i] = i*w0}; {eq1[i] =
=eq
>/. w -> w[i]}; {k[j] =  j*dk}; b[i, j] = eq1[i]/.k-> k[j]}];bet[i] =
>Min[bet[i, j]], {i, 1, 5}, {j, 1, 5}] ; When I try to name the Do
>loop and export to excel, it exports the whole matrix with the size
>5*5. How can I export the vector bet[i] from the loop?

A key issue is bet[i] is not a vector in Mathematica. In
Mathematica, this notation is the function bet evaluated at i.

I can create a 2D list that can be seen as a matrix by doing:

In:= b = Table[10 i + j, {i, 3}, {j, 3}];
b[]

Then I can access the 2nd row by:

Out= {21,22,23}

or the 2nd column by:

In:= b[[All, 2]]

Out= {12,22,32}

and Export["filename.xls", b[], "XLS"] will export just the
second row to Excel. However, when done this way, the elements
of b[] will appear in a single column rather than a single
row. If you want them in a single row then
Export["filename.xls", List/@b[], "XLS"] should do that.

```

• Prev by Date: Re: Intel MKL 10
• Next by Date: Re: Creating a hybrid cell
• Previous by thread: Re: Exporting a vector
• Next by thread: if using Mathematica to solve an algebraic problem is like copying