-6

I want to plot following function in Mathematica:

$f(x) = \frac{x}{x+c}$

I used the following command.

ListPlot[x/(x+c), {c, 1,10}, {x, 0, 10, 0.1}]

But it does not give me legends like which plot belongs to which value of c. Need help ASAP.

Sjoerd C. de Vries
  • 65,815
  • 14
  • 188
  • 323
Monty
  • 1
  • 1
  • 1
    Use Plot3D[x/(x+c),{c,1,10},{x,0,10}] or if you want to plot your function multiple times for different c, use Plot[Evaluate@Table[x/(x+c),{c,1,10}],{x,0,10}] – Julien Kluge Apr 23 '17 at 10:26
  • @JulienKluge: What i wrote does the trick but I want mathematica to show me which plot corresponds to which value of c. – Monty Apr 23 '17 at 10:37
  • 4
    See my answer. And no, your given code isn't even valid MMA code. – Julien Kluge Apr 23 '17 at 10:40

1 Answers1

5

You should really use Plot

Plot[Evaluate@Table[x/(x+c),{c,1,10}],{x,0,10},PlotLegends->"Expressions"]

evaluates to:

enter image description here

Explanation:

1.

Table[x/(x+c),{c,1,10}]

Evaluates to your functions, for the given Range of c.

{x/(1+x),x/(2+x),x/(3+x),x/(4+x),x/(5+x),x/(6+x),x/(7+x),x/(8+x),x/(9+x),x/(10+x)}

2.

Evaluate@Table[...

Evaluate forces Mathematica to evaluate the Table-expression. This must be done, because Plot holds its arguments. See here.

3.

PlotLegends->"Expressions"

Is an option for Plot and says Mathematica, that it should use the function-expressions as PlotLegends.

Julien Kluge
  • 5,335
  • 1
  • 17
  • 29