MathGroup Archive 2008

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

Search the Archive

Re: mathematica newbie ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92442] Re: mathematica newbie ?
  • From: Peter Breitfeld <phbrf at t-online.de>
  • Date: Tue, 30 Sep 2008 21:53:44 -0400 (EDT)
  • References: <gbt2pe$lcc$1@smc.vnet.net>

Jared.webb at yahoo.com schrieb:
> 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
>

Hi Jared,
do you want something like this:

nsupports = 3;
ndof = 10;
nels = 2;
int = Range[0, nsupports - 1];
ff[0] = 0;
ff[nsupports - 1] := ndof - 2
ff[x_] := 2 x nels;

Map[ff, int]

Out= {0,4,8}

Gruss Peter
-- 
==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de


  • Prev by Date: Re: ContourStyle -> {{Dashing[0.15, 0.5]}} has no effect
  • Next by Date: Re: mathematica newbie ?
  • Previous by thread: Re: mathematica newbie ?
  • Next by thread: Re: mathematica newbie ?