Mathematica - 2D plot for function of 2 vars?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 5K views
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.