0
$\begingroup$

I have list of functions such that

test = {test1[a,x], test2[a,x], test3[a,x]};

I would like to plot this three function using manipulation

Manipulate[Plot[test[[i]],{x,0,1}],
,{i,{1,2,3}},{a,0,1}]

So I want to generate the function by selecting i, but actually it does not respond the manipulate. How shall I solve the issue?

Example

f1[x_, x1_] := x^2 + x1^2
f2[x_, x1_] := x^3 + x1
f3[x_, x1_] := x + x1
ftest = {f1[x, x1], f2[x, x1], f3[x, x1]};
Manipulate[Plot[ftest[[i]], {x, -1, 1}], {i, {1, 2, 3}}, {x1, 0, 10}]
$\endgroup$
  • 1
    $\begingroup$ Instead: ftest = {f1, f2, f3}; Manipulate[Plot[ftest[[i]][x, x1], {x, -1, 1}], {i, {1, 2, 3}}, {x1, 0, 10}]. Part (if not all) of the problem is localization of variable x1 inside Manipulate. $\endgroup$ – march Mar 25 '16 at 18:04
1
$\begingroup$
f1[x_, x1_] := x^2 + x1^2
f2[x_, x1_] := x^3 + x1
f3[x_, x1_] := x + x1
ftest = {f1, f2, f3};
Manipulate[Plot[ftest[[i]][x, x1], {x, -1, 1}], {i, {1, 2, 3}}, {x1, 0, 10}]

enter image description here

Alternatively, without having to define ftest:

Manipulate[Plot[f[x, x1], {x, -1, 1}], {f, {f1, f2, f3}}, {x1, 0, 10}]
| improve this answer | |
$\endgroup$

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.