Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13663 > unrolled thread
| Started by | Tomas Garza <tgarza10@msn.com> |
|---|---|
| First post | 2013-03-02 07:34 +0000 |
| Last post | 2013-03-02 07:34 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: how to set initial values to symbolic variable array? Tomas Garza <tgarza10@msn.com> - 2013-03-02 07:34 +0000
| From | Tomas Garza <tgarza10@msn.com> |
|---|---|
| Date | 2013-03-02 07:34 +0000 |
| Subject | Re: how to set initial values to symbolic variable array? |
| Message-ID | <kgsa2l$ing$1@smc.vnet.net> |
Perhaps something like this:
In[1]:= Clear[a,r]
In[2]:= Array[a,4]
Out[2]= {a[1],a[2],a[3],a[4]}
In[3]:= f=a[1]+a[2]+a[3]+a[4]
Out[3]= a[1]+a[2]+a[3]+a[4]
In[4]:= r=Table[a[j]->1,{j,1,4}]
Out[4]= {a[1]->1,a[2]->1,a[3]->1,a[4]->1}
In[5]:= f/.r
Out[5]= 4
-Tomas
> From: devout1977@gmail.com
> Subject: how to set initial values to symbolic variable array?
> To: mathgroup@smc.vnet.net
> Date: Wed, 27 Feb 2013 23:45:55 -0500
>
>
> Dear All,
>
> Suppose I defined a symbolic variable array as
>
> Array[a,4]
>
> and defined a function as
>
> f = a[1] + a[2] + a[3] + a[4]
>
> I need to evaluate the value of f in the following way,
>
> f/.{a[1]->1,a[2]->1, ...}
>
> but specify each element of the array one by one is very troublesome, and I
> wonder whether there is something like a group definition like
>
> f/.{a[1:4]->1}
>
> to define the four variables at the same time with the same value.
>
> Thanks for your help,
>
> Sincerely,
> John
>
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web