0
$\begingroup$

I am trying to plot multiple curves for a particular parameter in a function S1, where the only variable is t and the rest are parameters.

S1[t_, alpha1_, alpha2_]:=40 + 2.82*t^(alpha1)/Gamma[alpha1 + 1]- 
   137.6*t^(alpha1)/Gamma[alpha1 + 1]-8.82*t^(2*alpha1)/Gamma[2*alpha1 + 1] - 
   52.68*t^(alpha1 + alpha2)/Gamma[alpha1 + alpha2 + 1]+
   129.61*t^(2*alpha1)/Gamma[2*alpha1 + 1]+29.85*t^(3*alpha1)/Gamma[3*alpha1 + 1];

For plotting, I adapted the idea from here.

Plot[Evaluate@Table[S1[t, alpha1, 2], {alpha1, 0.1, 0.15, 0.2}], {t, 
  0, 2}, PlotLegends ->LineLegend[Table[alpha1, {alpha1, 0.1, 0.15, 0.2}], 
   LegendLabel -> alpha1]]

But the output shows only one curve, just for the first entry of alpha1.

$\endgroup$
6
  • 2
    $\begingroup$ {alpha1, 0.1, 0.15, 0.2} means that alpha runs form 0.1 to 0.15 with step 0.2, this gives you one point at alpha=0.1 $\endgroup$
    – BlacKow
    May 24, 2016 at 15:00
  • $\begingroup$ @BlacKow oh my... I thought that this should take alpha1 to be 0.1, 0.15 and 0.2, displaying three distinct curves for each alpha1. How can we achieve that? $\endgroup$
    – zhk
    May 24, 2016 at 15:04
  • 1
    $\begingroup$ Have a look Mapping multiple parameters of a function to specific values $\endgroup$
    – user9660
    May 24, 2016 at 15:05
  • 2
    $\begingroup$ {alpha1, {0.1, 0.15, 0.2}} will give your points $\endgroup$
    – BlacKow
    May 24, 2016 at 15:05
  • 1
    $\begingroup$ @BlacKow, please make it an answer, so we can close this QnA sucessfully. $\endgroup$
    – user9660
    May 24, 2016 at 15:17

1 Answer 1

4
$\begingroup$

As requested, posting my comment as an answer. The Table takes {alpha1, {0.1, 0.15, 0.2}} to iterate alpha1 over the list

S1[t_, alpha_, n_] := Sin[100 alpha t];

Plot[Evaluate@Table[S1[t, alpha1, 2], {alpha1, {0.1, 0.15, 0.2}}], {t,
   0, 2}, PlotLegends -> 
  LineLegend[Table[alpha1, {alpha1, {0.1, 0.15, 0.2}}], 
   LegendLabel -> alpha1]]

enter image description here

$\endgroup$

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