Re: mathematica newbie ?
- To: mathgroup at smc.vnet.net
- Subject: [mg92411] Re: mathematica newbie ?
- From: Szabolcs Horvát <szhorvat at gmail.com>
- Date: Tue, 30 Sep 2008 21:47:58 -0400 (EDT)
- Organization: University of Bergen
- References: <gbt2pe$lcc$1@smc.vnet.net>
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. > Jared, 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 nsupports=3 ndof=10 nels=2 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!