MathGroup Archive 2008

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

Search the Archive

Re: mathematica newbie ?

  • To: mathgroup at
  • Subject: [mg92411] Re: mathematica newbie ?
  • From: Szabolcs Horvát <szhorvat at>
  • Date: Tue, 30 Sep 2008 21:47:58 -0400 (EDT)
  • Organization: University of Bergen
  • References: <gbt2pe$lcc$>

Jared.webb at 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.


Please do try to come up with a descriptive subject line next.

Your question is not very clear to me---do you mean to "return" a value 
for each element of 'int'?  Or are you computing a single value from 
this vector?

In the former case just use


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

f /@ Range[0, nsupports-1]

And please do try to read the documentation before you ask such a vague 
question, and do tell us what it was exactly that you found confusing 
about it!

  • Prev by Date: Re: Font size in plot coordinates?
  • Next by Date: Re: Comparison between Mathematica and other symbolic systems
  • Previous by thread: Re: mathematica newbie ?
  • Next by thread: Re: mathematica newbie ?