MathGroup Archive 2007

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

Search the Archive

Re: ReadList and columns

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73975] Re: [mg73873] ReadList and columns
  • From: "Chris Chiasson" <chris at chiasson.name>
  • Date: Sat, 3 Mar 2007 23:54:23 -0500 (EST)
  • References: <200703021137.GAA03851@smc.vnet.net>

AFAIK, nothing really needs to be transposed if you aren't using EDA:

au1={{350,0.00023179,0.0001804},{360,0.0038609,0.002927},{370,0.0075302,0.0058464},{380,0.008159,0.006915},{390,0.0076243,0.0068103}}

Show@Graphics[{Red,Line@au1[[All,{1,2}]],Blue,Line@au1[[All,{1,3}]]},AspectRatio->1,Frame->True]

On 3/2/07, Mary Beth Mulcahy <mulcahy.marybeth at gmail.com> wrote:
> Using Mathematicas Experimental Data Analysis (EDA) I have successfully
> written a notebook to import and plot numerous files.  EDA has some nice
> functions for importing data which include ignoring headers and specifying
> columns of data.  Unfortunately my colleague doesn't have EDA so I have been
> trying to write the script necessary to import the data the same way I have
> with EDA so that he can use my program.  I am close, but am at a stopping
> point I was hoping someone could help with.
>
> First, here is the one line of code I use in EDA to get my data ready:
>
> au1=Table[ImportData["C:\Documents and Settings\All
> Users\Documents\msb_chemistry\Argentina\ellipsometry\Gold\cavities\g500\Au5001.txt",HeaderLines->4,
> OutputVariables->1, UseVariables->i], {i, 1,19}];
>
>
> Here is what I have written to try and get my data into the same format not
> using EDA:
>
> strm=OpenRead["C:\Documents and Settings\All
> Users\Documents\msb_chemistry\Argentina\ellipsometry\Gold\cavities\g500\Au5001show.txt"];
>
>
> Skip[strm, Record, 4, NullRecords->False];  (*this is to eliminate 4 header
> lines*)
>
> au1=ReadList[strm, Table[Number, {i, 1, 19}]]; (this is to then import the
> data into a table*)
>
> Close[strm];
>
> Here is sample of what au1  then looks like according to Mathematica:
>
>  {{350,0.00023179,0.0001804},{360,0.0038609,0.002927},{370,0.0075302,
> 0.0058464},{380,0.008159,0.006915},{390,0.0076243,0.0068103}}
>
> which if I put in table form looks like:
>
> au1//TableForm
>
> 350    0.00023179    0.0001804
> 360    0.0038609    0.002927
> 370    0.0075302    0.0058464
> 380    0.008159    0.006915
> 390    0.0076243    0.0068103
>
>
> So in the end what I want to do is make a MultipleListPlot using the left
> column as the "x" column and then the two other as "y" columns.  Since with
> EDA I have been calling each column in as a separate variable, I simply
> transpose the two columns I want to plot to get my {x, y} points.  That
> doesn't work here.  When I call up the columns, I get a list of individual
> numbers:
>
> input:     au1[[All,{1}]]
> output:  {{350},{360},{370},{380},{390}}
>
> input:     au1[[All,{2}]]
> output:   {{0.00023179},{0.0038609},{0.0075302},{0.008159},{0.0076243}}
>
> And when I try and transpose the lists (Transpose[au1[[All,{1}]], au1[[All,
> {2}]]]) I get an error message saying the dimensions of my array are
> incorrect.
>
> I know that I need Mathematica to read my columns like this:
> {350,360,370,380,390} without the extra curly brackets and which I believe
> would be a single array, but I can't figure out how to do it.  I would
> really appreciate any help.
>
> Sincerely,
> Mary Beth Mulcahy
>
>


-- 
http://chris.chiasson.name/


  • Prev by Date: Re: Re: fastest way to add up a billion numbers
  • Next by Date: Re: Re: need MathLie mathematica package
  • Previous by thread: RE: ReadList and columns
  • Next by thread: Re: ReadList and columns