I'm plotting this function.

Plot[rs + ts+ s, {r == 2},{t==3} {s, 2, 5}] or

[{t=3, r=2}, Plot[ r s + t s + s, {s, 2, 5}]]

When I substitute the value of "r" in the expression then its plot graph, but for unknown "r and t" in expression and further declaration the value of "r and t", its unable to draw.

Is there any alternate method to plot the expressions with given fixed values of some variable and with given range of some other variable.

  • $\begingroup$ You mean something like With[{t=3, r=2}, Plot[ r s + t s + s, {s, 2, 5}]]? $\endgroup$ – Kuba Nov 19 '17 at 20:05
  • $\begingroup$ yes sir, but its not still working Kuba $\endgroup$ – Dauood Saleem Nov 19 '17 at 20:15
  • $\begingroup$ It's unclear what you're asking. Do you mean you want to plot a surface? e.g. With[{t=3}, Plot3D[ r s + t s + s, {r, 0, 2}, {s, 2, 5}]] $\endgroup$ – b3m2a1 Nov 19 '17 at 20:31
  • $\begingroup$ Welcome to Mathematica StackExchange. In order to learn how to use this site take the tour. When copying equations from a notebook to your question one should format using inline code by selecting the code and clicking the {} button above the edit window. It is recommended that you browse the Markdown help $\endgroup$ – Jack LaVigne Nov 19 '17 at 22:01
  • $\begingroup$ Thank you so much, sir. $\endgroup$ – Dauood Saleem Nov 20 '17 at 9:15

If you want r and t to vary, you can try this

Manipulate[Plot[r s + t s + s, {s, 2, 5}], {r, 1, 4}, {t, 0, 5}]
  • $\begingroup$ Thank you so much sir, Bill Watts. $\endgroup$ – Dauood Saleem Nov 20 '17 at 8:57

Another possibility would be to define a function that computes the expression with input arguments that include the parameters r and t.

f[s_, r_, t_] := r s + t s + s

Now when you plot it set the value of the variables, r=2, t=3.

Plot[f[s, 2, 3], {s, 2, 5}]

Mathematica graphics

  • $\begingroup$ Thank you so much sir, Jack LaVigne. $\endgroup$ – Dauood Saleem Nov 20 '17 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.