# Getting named functions from an sequence of parameter values applied to a parametric function [closed]

The general question is how can I loop on names and indices?

An example:

I have

pfun = ParametricNDSolveValue[{y'[t] == a y[t], y == b}, y, {t, 0, 10}, {a,b}]


and I want

y11 = pfun[1, 1]
y12 = pfun[1, 2]
...


How can I generate a list of $$yXY$$ with $$X=a$$ and $$Y=b$$?

• y = Table[pfun[a, b], {a, 1, 3}, {b, 1, 5}]? – Alan Apr 17 '19 at 11:31
• y = pfun @@@ Tuples[{Range, Range}]? – Henrik Schumacher Apr 17 '19 at 12:38

## 1 Answer

It is a common mistake of beginners to think they need names to refer to the results of ParametricNDSolveValue. I don't say naming is never needed, but it is very seldom needed.

Suppose you wanted to see a plot of the curves that you suggest labeling y11, y12, ..., y14. This can be done without labeling:

Plot[Evaluate[Table[pfun[1, b][t], {b, 4}]], {t, 0, 10}, PlotLegends -> Automatic] This approach also has the advantage of allowing you to use parameter values which are not integer index values, which I think will be something you will want to do.

Plot[Evaluate[Table[pfun[.12, b][t], {b, 4}]], {t, 0, 10}, PlotLegends -> Automatic] 