|
[Date Index]
[Thread Index]
[Author Index]
Re: filling in an array
- To: mathgroup at smc.vnet.net
- Subject: [mg55369] Re: filling in an array
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Sun, 20 Mar 2005 04:12:07 -0500 (EST)
- References: <d1guie$sc$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
dumb_founded wrote:
> How can I input values into an array most efficiently? I tried the
> code below, but it doesn't work. The kernel starts working through the
> loop and never gets out.
>
> Array[b, 10];
> For[i = 1, i = 10, b[i] = i/10]
>
Hi,
If a Mathematica command does not work as I expect, the first thing I do
is click on the command name and press F1 to bring up the help
information - which is very comprehensive. That would tell you that the
syntax of the For command (in your context) is:
For[i = 1, i < 11, i++,b[[i]]=i/10]
Note that arrays are indexed using double square brackets, single ones
are used for function arguments.
Rather than struggle like this, why not take a short course on
Mathematica. People here can only correct the odd problems you present,
and I think if you learned how to write good-quality Mathematica code
you would never look back!
David Bailey
dbaileyconsultancy.co.uk
Prev by Date:
Re: plotting weighted graphs
Next by Date:
Re: Problem with singularities in Plot3D
Previous by thread:
Re: filling in an array
Next by thread:
Re: Distance from point to set
|