# Plotting a function of 3 variables while keeping 2 of them fixed

For illustration I made a simplified version of my function:

testfunct[a_, b_, c_] := Module[{e1,e2,e3},
e1 = a + 2 b + c;
e2 = a- b;
e3 = a+b+2;
{e1,e2,e3}
];


Such that I can enter any variables

testfunct[1, 2, 3]

and expect some result list of values. Now what I'd want to do is to keep a and c fixed while running b from 1 to 10 and plot only the resulting e1 against b.

Let's say a = 1, c = 1 and we make a table or a for loop for b = 0,...,10. We get 10 results for e1.

Now I want to have b on the x axis and b on the y axis for all 10 values.

There are many ways. Here is one.

testfunct[a_, b_, c_] := a + 2 b + c;
Plot[testfunct[1, y, 1], {y, 1, 10}]


You can similarly partially apply only one argument:

Plot3D[testfunct[x, y, 10], {x, 0, 1}, {y, 1, 10}]


Edit:

After the change in the question, you can do:

testfunct[a_, b_, c_] := {a + 2 b + c, a - b, a + b + 2}
Plot[testfunct[1, y, 1][[1]], {y, 1, 10}]

• I'm afraid it's not that easy. To be more exact my testfunct function creates a list/string of many different values (see the updated description). And don't forget the module in front. So the result looks sth. like this {e1,e2,e3} No I am only interested in e1. I could do Plot[testfunct[1, y, 1][[1]], {y, 1, 10}] but this does not work. Jan 9, 2019 at 22:07
• Oh I did not know that, sorry. As a beginner (on both mathematica and stack exchange) I didn't think I changed much. Jan 9, 2019 at 22:42
• @BenjaminJabl See the answer edit.
– Alan
Jan 9, 2019 at 22:45
• Sadly is still does not work :/ After I try to make the plot the programm ist just stuck in a seemingly endless loop. Plot[funct[1, y, 10][[8]], {y, 1, 10}] Is what I wrote and didn't work. While 'funct[1, 1, 10][[8]]' produces the exact desired result. One more thing I could think of is to alter the function such that 'funct[1, 1, 10][[8]]' provides me with a pair {b,e1}. But I am unable to make more than just 1 pair at a time :/ Jan 9, 2019 at 22:56
• Never mind it work ! Thank you for your time & help Jan 9, 2019 at 23:02