1
$\begingroup$

I want to plot a graph of a function in one command

y=Sin[a+bx+c]+d;

for the range of x=[0,10] for the below set of values

1.a=1,b=1,c=1,d=1

2.a=1.5,b=1.5,c=1.5,d=1.5

3.a=2,b=2,c=2,d=2

$\endgroup$

1 Answer 1

2
$\begingroup$
rules = Thread[{a, b, c, d} -> #] & /@ {1, 1.5, 2};
Plot[Evaluate[Sin[a + b x + c] + d /. rules], {x, 0, 10}, 
 PlotLegends -> ToString /@ rules]

enter image description here

rule4 = Thread[{a, b, c, d} -> {1, 2, 4, 3}]

{a -> 1, b -> 2, c -> 4, d -> 3}

rulesb =  Append[rules, rule4];

Plot[Evaluate[Sin[a + b x + c] + d /. rulesb], {x, 0, 10}, 
  PlotLegends -> ToString /@ rulesb]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you. It's great. if values of variables are different from each other then how can plot. like a=1,b=1.2,c=1.4,d=1.6 a=2,b=2.2,c=2.4,d=2.6 a=3,b=3.2,c=3.4,d=3.6 $\endgroup$ Mar 12, 2020 at 7:04
  • 1
    $\begingroup$ @Mathematicain, please see the update. $\endgroup$
    – kglr
    Mar 12, 2020 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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