Mathematica Mathematica - 2D plot for function of 2 vars?

AI Thread Summary
To create a series of 2D plots of a function f(a,b) versus a for discrete values of b, one effective approach is to define a new function f1(b) that mirrors f(a,b). The command Plot[{f1[10], f1[20], f1[50], f1[100]}, {a, 1, 10}] can be used to generate the desired plots on the same graph. For further automation, using a table can streamline the process: Plot[Table[f1[i], {i, 1, 100, 5}], {a, 1, 10}] allows for plotting multiple values of b efficiently, making it easier to visualize the function across a broader range of values.
dcnicholls
Messages
6
Reaction score
0
I have a function of two variables, f(a,b). I want to create a series of 2D plots (on the same plot) of f(a,b) vs a, for a=1 to 10, for a set of discrete values of b (e.g. b=10,20,50,100).

Is there a simple way to do this? Plot3D works, but I cannot find how to do it in 2D.

DN
 
Physics news on Phys.org
Solved: Define a second function f1(b) with the same formula as f(a,b), and use:

Plot[{f1[10],f1[20],f[50],f[100]},{a,1,10}]

Does the job.

DN
 
Also if you want to automoate it more you can make it a table:

Plot[Table[f1,{i,1,100,5}],{a,1,10}]

Makes a table of f1 as i goes from 1 to 100 by 5. Easier if you want a lot of them.
 
Thanks, useful improvement.
 
Back
Top