Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1808
| From | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Converting list of subscripted variables into an array |
| Date | 2011-04-21 07:10 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <iool9j$boc$1@smc.vnet.net> (permalink) |
This might get you started:
Clear[subFunction]
subFunction[
a_Symbol] := (MakeExpression[SubscriptBox[ToString@a, i_], f_] :=
MakeExpression[RowBox[{ToString@a, "[", i, "]"}]];
MakeBoxes[a[i_], f_] :=
SubscriptBox[MakeBoxes[a, f], MakeBoxes[i, f]])
subFunction[c]
Array[c[#1][#2] &, {9, 2}]
{{Subscript[c, 1][1], Subscript[c, 1][2]}, {Subscript[c, 2][1],
Subscript[c, 2][2]}, {Subscript[c, 3][1],
Subscript[c, 3][2]}, {Subscript[c, 4][1],
Subscript[c, 4][2]}, {Subscript[c, 5][1],
Subscript[c, 5][2]}, {Subscript[c, 6][1],
Subscript[c, 6][2]}, {Subscript[c, 7][1],
Subscript[c, 7][2]}, {Subscript[c, 8][1],
Subscript[c, 8][2]}, {Subscript[c, 9][1], Subscript[c, 9][2]}}
Bobby
On Wed, 20 Apr 2011 03:27:29 -0500, Christopher O. Young
<cy56@comcast.net> wrote:
>
> I have a long list that's supposed to represent points on 9 different
> curves. I'd like to put them into an array C[j,k] where j is the index
> for
> the curves and k is the index for the points.
>
> Subscript[c1, 1] = {1.796875, 1.34375}
>
> Subscript[c1, 2] = {2.15625, 1.34375}
>
> Subscript[c1, 3] = {2.296875, 1.359375}
>
> Subscript[c1, 4] = {2.375, 1.46875}
>
> Subscript[c1, 5] = {2.46875, 1.671875}
> ......
>
> I'm new at pattern matching, and I'm having a hard time getting started
> here. Can anyone steer me in the right direction?
>
> Chris Young
> cy56@comcast.net
> IntuMath.org
>
> In[180]:= "c" <> IntegerString[1]
>
>
> Out[180]= "c1"
>
>
>
>
> In[181]:= Subscript["c" <> IntegerString[1], 2]
>
>
> Out[181]= Subscript["c1", 2]
>
>
>
>
> In[182]:= Evaluate[%]
>
> In[183]:= Subscript["c1", 2]
>
>
> Out[183]= Subscript["c1", 2]
>
>
>
>
> ToExpression[Subscript["c1", 2]]
>
>
>
> During evaluation of In[187]:= ToExpression::notstrbox: Subscript[c1, 2]
> is
> not a string or a box. ToExpression can only interpret strings or boxes
> as
> Mathematica input. >>
>
>
>
> Out[187]= $Failed
>
>
>
>
> In[188]:= ToExpression[RowBox[{Subscript["c1", 2]}]]
>
>
>
> During evaluation of In[188]:= ToExpression::esntx: Could not parse
> RowBox[{Subscript[c1, 2]}] as Mathematica input. >>
>
>
>
> Out[188]= $Failed
>
>
>
>
>
--
DrMajorBob@yahoo.com
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Converting list of subscripted variables into an array DrMajorBob <btreat1@austin.rr.com> - 2011-04-21 07:10 +0000
csiph-web