Hello,
If one solves a single ODE by NDSolve, the following function un[t_] correctly evaluates the numerical solution obtained:
sol0=NDSolve[{u'[t]+u[t]==0,u[0]==1},u[t],{t,0,1}];
un[t_]:=Evaluate[First[u[t]/.sol0]];
un[1/2]
0.606531
My question is: how to define a corresponding function in the case of an ODE system? My following attempt to devise an analogous function failed:
sol=NDSolve[{Subscript[u, 1]'[t]+Subscript[u, 1][t]-Subscript[u, 2][t]==0,Subscript[u, 2]'[t]-Subscript[u, 1][t]+Subscript[u, 2][t]==0,Subscript[u, 1][0]==1,Subscript[u, 2][0]==2},{Subscript[u, 1][t],Subscript[u, 2][t]},{t,0,1}];
Subscript[uns, i][t_]:=Evaluate[sol[[1]][[i]][[2]]];
Part::pkspec1: The expression i cannot be used as a part specification.
Subscript[uns, 1][1/2]
It seems that "i" must be a predefined constant, so how one can access a relevant FunctionInterpolation object corresponding to a variable "i"? Or is there a better alternative?
Lesław