       Re: mathematica newbie ?

• To: mathgroup at smc.vnet.net
• Subject: [mg92439] Re: [mg92376] mathematica newbie ?
• From: Murray Eisenberg <murray at math.umass.edu>
• Date: Tue, 30 Sep 2008 21:53:10 -0400 (EDT)
• Organization: Mathematics & Statistics, Univ. of Mass./Amherst
• References: <200809301133.HAA21913@smc.vnet.net>
• Reply-to: murray at math.umass.edu

```To begin, I hardly thing there's any difficulty whatsoever in the stated
case where nsupports=3, since you have then a list of just 3 elements.
so let's try something a little more ambitious, where there are, say 6
elements:

nsupports = 6; ndof = 10; nels = 2;

Next, define a function v having two special rules and one general rule:

v = 0; v[nsupports - 1] = ndof - 2;
v[x_] := 2 x nels

Finally, form the column vector you want:

col = Table[{v[x]}, {x, 0, nsupports - 1}]
{{0},{4},{8},{12},{16},{8}}

The result is, in effect, a column vector -- although it's really just a
list of 6 one-element lists.  If you want to display it as a column
vector, do this:

col // MatrixForm

Jared.webb at yahoo.com wrote:
> I am extremely new to mathematica and am having trouble following the
> documentation.
>
> I would like to set up the following loop and have it send the output
> to a vector.
>
> If I have in mathematica:
>
> nsupports=3
> ndof=10
> nels=2
> int=range[0,nsupports-1]        - this is my iterator
>
> I want to set up a loop:
>
> for x in int:
> if x=0, return 0
> if x=nsupports-1, return ndof-2
> otherwise, return x*nels*2
>
> I want the output to go to a column vector.
>
> Thanks
> Jared
>

--
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

```

• Prev by Date: Re: Avoiding Null output marker from a function
• Next by Date: Re: Is there any simplier way to plot in a specific style?
• Previous by thread: mathematica newbie ?
• Next by thread: Re: mathematica newbie ?