MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Exporting a vector

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

On 4/5/10 at 8:02 AM, sagittarius5962 at (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] =
>/. 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[1]:= b = Table[10 i + j, {i, 3}, {j, 3}];

Then I can access the 2nd row by:

Out[2]= {21,22,23}

or the 2nd column by:

In[3]:= b[[All, 2]]

Out[3]= {12,22,32}

and Export["filename.xls", b[[2]], "XLS"] will export just the
second row to Excel. However, when done this way, the elements
of b[[2]] 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[[2]], "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