0
$\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$
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$
  • $\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$ – Mathematicain Mar 12 '20 at 7:04
  • 1
    $\begingroup$ @Mathematicain, please see the update. $\endgroup$ – kglr Mar 12 '20 at 7:12
  • $\begingroup$ @Mathematicain, my pleasure. $\endgroup$ – kglr Mar 12 '20 at 7:16

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.