RE: ReadList and columns
- To: mathgroup at smc.vnet.net
- Subject: [mg73956] RE: [mg73873] ReadList and columns
- From: "David Annetts" <davidannetts at aapt.net.au>
- Date: Sat, 3 Mar 2007 01:21:33 -0500 (EST)
- References: <200703021137.GAA03851@smc.vnet.net>
Hi Mary Beth
> 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.
You're kind of on the right track ....
Given
data = {{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}};
One sequence of commands to get you what you want is
pdata = Transpose@data; (* essentially isolates each of the columns
*)
pdata = {First@pdata, pdata[[#]]} & /@ Range[2, Length@pdata] (*
form pairs always using the first column as the first
entry in each array *)
pdata = Map[Transpose, pdata] (* place your data into the correct
form for MLP *)
MultipleListPlot[pdata]; (* 'nuff said *)
It should be straightforward for you to write a function that does this
stuff automagically.
Regards,
Dave.
- References:
- ReadList and columns
- From: "Mary Beth Mulcahy" <mulcahy.marybeth@gmail.com>
- ReadList and columns