Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Mathematica - 2D plot for function of 2 vars?

  1. Mar 24, 2012 #1
    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.

  2. jcsd
  3. Mar 24, 2012 #2
    Solved: Define a second function f1(b) with the same formula as f(a,b), and use:


    Does the job.

  4. Mar 24, 2012 #3


    User Avatar
    Gold Member

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


    Makes a table of f1 as i goes from 1 to 100 by 5. Easier if you want a lot of them.
  5. Mar 24, 2012 #4
    Thanks, useful improvement.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook