Message Boards Message Boards

0
|
2555 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

[?] Plot function that has piecewise function within?

Posted 6 years ago

can anyone help me with plotting the graph as follows

e := 0.2;    bo := 1;    T := 2;    xo := 1;    x1 = -1;
u = Piecewise[{{1, -1 <= b <= 1 && (x^3) - 2*x + b > 0 || 
     b > 1 && x}}, 0]
PP = StreamPlot[{x - xo + (xo - x1)*u, -((x^3) - T*x + b)/e}, {b, -2, 
   2}, {x, -2, 2}]

This is the output

Attachments:
POSTED BY: Nur Syahirah

The last condition x in Piecewise is not a predicate: -1 <= b <= 1 && (x^3) - 2*x + b > 0 || b > 1 && x. This variation works:

e = 0.2; bo = 1; T = 2; xo = 1; x1 = -1;
u[b_, x_] := 
  Piecewise[{{1, -1 <= b <= 1 && (x^3) - 2*x + b > 0 || 
      b > 1 && x > 1}}, 0];
StreamPlot[
 PiecewiseExpand[{x - xo + (xo - x1)*u[b, x], -((x^3) - T*x + b)/
    e}], {b, -2, 2}, {x, -2, 2}]

I don't know why we need PiecewiseExpand.

POSTED BY: Gianluca Gorni
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