[Date Index]
[Thread Index]
[Author Index]
Re: Mathematica function writing for data analysis at Gould Academy
*To*: mathgroup at smc.vnet.net
*Subject*: [mg35722] Re: Mathematica function writing for data analysis at Gould Academy
*From*: "Allan Hayes" <hay at haystack.demon.co.uk>
*Date*: Sat, 27 Jul 2002 06:43:32 -0400 (EDT)
*References*: <ahr0u6$l2l$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Charles,
Below "fl" contains the following
Test Table
0 6 8
5 0 3
6 6 8
Using
MultColumn[fl_,n___]:=
Cases[Import[fl, "Table"], {x___?NumberQ}][[{n}]]
we get
MultColumn["fl",1,3]
{{0,6,8},{6,6,8}}
PS. For and While do not generate output -- we have to add this on:
n=1;While[ n<4, ++n];n
4
--
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: ToExpression**
Next by Date:
**Re: Mathematica function writing for data analysis at Gould Academy [Correction]**
Previous by thread:
**Mathematica function writing for data analysis at Gould Academy**
Next by thread:
**Re: Mathematica function writing for data analysis at Gould Academy**
| |