I would like to create two arrays of functions yfunc[[i]]
and tfunc[[i]]
, with each entry of those functions being a function depending on t, that is to say
yfunc={yfunc[[1]][t],yfunc[[2]][t],...}
and the same for tfunc
. Then I would also like to plot members of these array with ParametricPlot
in pairs, e.g.
ParametricPlot[{yfunc[[i]][t],tfunc[[i]][t]},{t,0,1}]
This code works:
yfunc[t_?NumericQ, i_?IntegerQ] := i*t;
tfunc[t_?NumericQ, i_?IntegerQ] := 2 i*t;
comp[i_] := {tfunc[t, i], yfunc[t, i]};
Show[ParametricPlot[comp[1], {t, 0, 1}], AspectRatio -> 1]
But another try of creating this function array fails:
yfunc[t_?NumericQ] := Table[i*t, {i, 1, 100}]
tfunc[t_?NumericQ] := Table[2 i*t, {i, 1, 100}];
comp[i_?IntegerQ] := {tfunc[[i]][t], yfunc[[i]][t]};
Show[ParametricPlot[comp[1], {t, 0, 1}], AspectRatio -> 1]
I guess in this case it is a problem with the evaluation. What would be the correct way to do it in the second way?
Thanks!
comp[i_] := {tfunc[t, i], yfunc[t, i]}
(which works fine). Similarly for the second example:comp[i_] := {tfunc[t][[i]], yfunc[t][[i]]}
works. $\endgroup$ – kglr Jan 24 '13 at 10:04comp[i_] := {tfunc[t][[i]], yfunc[t][[i]]}
is that first every function in the vector gets evaluated only to choose one value of interest in the end. This is of course no problem in the toy model i*t, but takes more time with longer arrays and more complicated functions. $\endgroup$ – malumno Jan 24 '13 at 10:13