Skip to main content

Sure, one way is to use patterns and replacement rules (check out Symbol):

{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]} /. Subscript[x_, k_] :> Symbol[ToString[x] <> ToString[k]]StringReplace[ToString[k]," "->""]] (* {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10} *) 

as a function you can use:

appendSub[exp_] := exp /. Subscript[x_, k_] :> Symbol[ToString[x] <> ToString[k]]StringReplace[ToString[k]," "->""]] appendSub[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]}] (* {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10} *) 

Sure, one way is to use patterns and replacement rules (check out Symbol):

{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]} /. Subscript[x_, k_] :> Symbol[ToString[x] <> ToString[k]] (* {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10} *) 

as a function you can use:

appendSub[exp_] := exp /. Subscript[x_, k_] :> Symbol[ToString[x] <> ToString[k]] appendSub[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]}] (* {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10} *) 

Sure, one way is to use patterns and replacement rules (check out Symbol):

{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]} /. Subscript[x_, k_] :> Symbol[ToString[x] <> StringReplace[ToString[k]," "->""]] (* {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10} *) 

as a function you can use:

appendSub[exp_] := exp /. Subscript[x_, k_] :> Symbol[ToString[x] <> StringReplace[ToString[k]," "->""]] appendSub[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]}] (* {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10} *) 
Source Link
chuy
  • 11.4k
  • 29
  • 49

Sure, one way is to use patterns and replacement rules (check out Symbol):

{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]} /. Subscript[x_, k_] :> Symbol[ToString[x] <> ToString[k]] (* {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10} *) 

as a function you can use:

appendSub[exp_] := exp /. Subscript[x_, k_] :> Symbol[ToString[x] <> ToString[k]] appendSub[{Subscript[x, 1], Subscript[x, 2], Subscript[x, 3], Subscript[x, 4], Subscript[x, 5], Subscript[x, 6], Subscript[x, 7], Subscript[x, 8], Subscript[x, 9], Subscript[x, 10]}] (* {x1, x2, x3, x4, x5, x6, x7, x8, x9, x10} *)