I have a list of solutions Subscript[x, 1][t], i = 1,...,n (n given).

I would like to use these variables to define new variables such as:

i = 1;
For[i = 1, i <= n, i++, 
 Subscript[X, i][t_] := Subscript[x, i][t] /. sol]

I know that this code is not working and I know why. However, I would like to ask you if there is a way how to define these variables at once (without having to define them one by one)?

Thank you very much in advance for your help.


  • 1
    $\begingroup$ TIP: never use Subscript nor For. They are one of the main sources of confusion. $\endgroup$ – AccidentalFourierTransform Nov 30 '19 at 18:15
  • $\begingroup$ Here you could try Table[X[i][t_] := x[i][t] /. sol, {i, 1, n}]. Does this work as expected? $\endgroup$ – AccidentalFourierTransform Nov 30 '19 at 18:16
  • $\begingroup$ Thank you very much, I replaced Substrict and with some more changes itw working properly now. Many thanks! $\endgroup$ – derdin1 Nov 30 '19 at 19:08

You can use Inactive to postpone the SetDelayed operation until after the RHS has been defined. Here is an example:

sol = Subscript[x, i_][t] -> t^i;
n = 10;

Activate @ Table[
    {i, n}


Subscript[X, 4][2]


  • $\begingroup$ Many thanks, that helped me a lot! $\endgroup$ – derdin1 Nov 30 '19 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.