Message Boards Message Boards

GROUPS:

Using Manipulate on a piecewise function made of specific parameters ?

Posted 15 days ago
205 Views
|
4 Replies
|
1 Total Likes
|

Hi, I'm trying to put on Mathematica a graph of my model that is displaying a piecewise function with specific parameters. The aims being to see how the parameters will affect the graph I wanted to do it on Mathematica with manipulate. I join the Mathematica file to my question hopping one can tell me why I cannot see anything else than a blank sheet. I tried to do it in two stages as my tries in once were giving something worst. Thanks in advance for any advice that I might use!

This is the piecewise function I need to graph.

fb[Fc_] := 
 Piecewise[{{a^2 (1 + \[Beta] (1 - p))/
     2 (1/(2 (b + cB + \[Tau]*\[Theta]B)) - 1/(
       2 (b + cA + \[Tau]*\[Theta]A))), 
    0 <= Fc <= 
     a^2/2 (1/(2 (b + cC + \[Tau]*\[Theta]C)) - 1/(
        2 (b + cB + \[Tau]*\[Theta]B)))}, {a^2 ((1 + \[Beta])/(
        2 (b + cB + \[Tau]*\[Theta]B)) - (1 + \[Beta] (1 - p))/(
        2 (b + cA + \[Tau]*\[Theta]A)) - (\[Beta]* p)/(
        2 (b + cC + \[Tau]*\[Theta]C))) + \[Beta] *p*Fc, 
    a^2/2 (1/(2 (b + cC + \[Tau]*\[Theta]C)) - 1/(
        2 (b + cB + \[Tau]*\[Theta]B))) < Fc <= 
     a^2/2 (1/(2 (b + cC + \[Tau]*\[Theta]C)) - 1/(
        2 (b + cA + \[Tau]*\[Theta]A)))}}]

And this is how I try to plot it:

Manipulate[
 Plot[fb[Fc_], {Fc, 0, 
   a^2/2 (1/(2 (b + cC + \[Tau]*\[Theta]C)) - 1/(
      2 (b + cA + \[Tau]*\[Theta]A)))}], {a, 1, 5}, {\[Theta]A, 0, 
  1}, {\[Theta]B, 0, 1}, {\[Theta]C, 0, 1}, {\[Tau], 0, 3}, {cA, 2, 
  3}, {cB, 1, 2}, {cC, 0, 1}, {b, 0, 1}, {p, 0, 1}, {\[Beta], 0, 1}]
Attachments:
4 Replies
Posted 15 days ago

Hi Xavier,

There are at least two issues

Plot[fb[Fc_], ...]

should be

Plot[fb[Fc], ...]

After fixing that

Power::infy: Infinite expression 1/0 encountered.

The range for Fc includes this expression

1/(2 (b + cC + τ*θC))

The range for b, cC, τ and θC in the Manipulate all start at 0 causing the 1/0 error.

Thank you for your comment! Indeed I forgot to put at least 0.1 however I still do not see anything when looking at the graph... :/

Posted 15 days ago

After applying Rohits fixes and tweaking a bit, this will show a graph:

Manipulate[
    Plot[
        fb[Fc], 
        {Fc, 0,  a^2/2 (1/(2 (b + cC + \[Tau]*\[Theta]C)) - 1/(2 (b + cA + \[Tau]*\[Theta]A)))},
        Exclusions -> None, PlotRange -> Full, AxesOrigin -> {0,0}
    ],
    {{a,2}, 1, 5}, {\[Theta]A, 0, 1}, {\[Theta]B, 0, 1}, {\[Theta]C, 0.1, 1}, {\[Tau], 0.1, 3}, 
    {cA, 2, 3},{cB, 1, 2}, {cC, 0.1, 1}, {b, 0.1, 1}, {p, 0, 1}, {\[Beta], 0, 1},
    SaveDefinitions -> True
 ]

Thanks a lot for your help this problem is now fixed!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract