Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: Mathematica function writing for data analysis at Gould Academy [Correction]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35726] Re: Mathematica function writing for data analysis at Gould Academy [Correction]
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 27 Jul 2002 06:43:41 -0400 (EDT)
  • References: <ahr0u6$l2l$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Charles has pointed out that my previous posting gave rows and he wanted
columns.
The following gives columns.

MultColumn[fl_,n___]:=Cases[Import[fl,"Table"],{x___?NumberQ}][[All,{n}]]

Test

   MultColumn["fl",1,3]

        {{0,8},{5,3},{6,8}}

We can do more:

    MultColumn["fl",3,1]

        {{8,0},{3,5},{8,6}}

    MultColumn["fl",3,1,3]

        {{8,0,8},{3,5,3},{8,6,8}}


--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Charles H. Dresser" <dresserc at gouldacademy.org> wrote in message
news:ahr0u6$l2l$1 at smc.vnet.net...
> Hello,
> I work at Gould Academy and have recently taught myself some of the
> Mathematica scripting language. It has been my job to write functions
> which will make analyzing data in Mathematica simpler for the
> students. I have written a number of scripts which find different
> regressions of data within a file easily. But, a couple of the
> functions that I have written are not doing exactly what I want them
> to do. One of them takes the input from a file with multiple columns
> and what number columns the user wants to be included in the data as
> ordered pairs and is suppose to output the ordered pairs which was
> selected. What it does is it doesn't output anything but does set list
> equal to the data which it should output.  This is the code I have
> written (Sorry If It Is Ugly):
>
> f is a filename x is the column which is wanted to be the x value in
> the order pairs y is the y value which is wanted to be the ordered
> pairs.
>
>   MultCol[f_, x_, y_] :=
>   Do[For[i = 1; list = {}; length = Length[Import[f, "Table"]], i <=
> length,
>         i++,
>         list =
>           Append[list, {Part[Part[Import[f, "Table"], i], x],
>               Part[Part[Import[f, "Table"], i], y]}]]
> MultColCleanUp[], {1}]
>
> MultColCleanUp[] :=
>   If[DigitQ[StringTake[ToString[First[list]], {2}]], list = list,
>     list = Rest[list]]
>
> What MultColCleanUp does is if there is a title  in the first part of
> the data it removes it from the list.
>
> I would like the students to be able to simply type
> MultCol["filename", 1, 3] and have the data in columns 1 and 3 in
> "filename" be put together and outputted to the screen in the form of
> a matrix.
>
> Also, I have another script I wrote which does relatively the same
> thing. What this script is a function which will take a part of data
> from a file. It will take data between in the form of ordered pairs in
> between the first x value entered and the second value entered. The
> Code is:
>
> FilePart[f_, n_, z_] :=
>   For[i = 1; list = {}; length = Length[Import[f, "Table"]], i <=
> length, i++,
>      If[z >= First[Part[Import[f, "Table"], i]] >= n,
>       list = Append[list, Part[Import[f, "Table"], i]];,
>       If[i >= length, list = list]]
>     ]
>
> I would like for the students to be able to simply type
> FilePart["filename", 3, 5] and get {{3,78}, {4,56}, {5,90}} as output.
> the Y values are just for example purposes.
>
> In both scripts it assigns the value of the data wanted to list, but
> does not display list to the screen as an output.
>
> Thank You Very Much! I have been stuck on these two scripts for quite
> some time now.
>




  • Prev by Date: Re: Mathematica function writing for data analysis at Gould Academy
  • Next by Date: Controlling font size in user-defined Palettes?
  • Previous by thread: More than one radical
  • Next by thread: Controlling font size in user-defined Palettes?