1
$\begingroup$

I am trying to define a function where H1[x_]= a previously derived value if 0 < x <100 and H1[x_]=x if x>100 so I have used the following piecewise function: H1[x_]:=Piecewise[{{Evaluate[y[x] /. s],0 < x < 100},{x, x > 100}}]. However when I plot this H1[x_] function it gives the graph after entering the following Plot[H1[x],{x,1,200}] Does anyone know why it is not taking the value of H1[x_]=x after x=100? thank you for your help

enter image description here

$\endgroup$
4
  • $\begingroup$ ... what is s? $\endgroup$
    – kglr
    Commented Aug 30, 2019 at 20:49
  • $\begingroup$ s = NDSolve[{y'[x] == f[x, y[x], -1.5, 1.25, 2, 1], y[100] == 99}, y, {x, 1,100.005}] where f is defined as: $\endgroup$
    – Max Toon
    Commented Aug 30, 2019 at 20:50
  • $\begingroup$ f[x_, y_, m_, n_, p_, K_] := (p x^(p - 1) y ((m + 1) (x/y)^n - (n + 1) (x/y)^m))/(((m + 1) (n + 1) x^p - n m K y) ((x/y)^n - (x/y)^m)) $\endgroup$
    – Max Toon
    Commented Aug 30, 2019 at 20:50
  • $\begingroup$ Thank you Max Toon. Please update your question with the information about f and s. $\endgroup$
    – kglr
    Commented Aug 30, 2019 at 21:04

1 Answer 1

4
$\begingroup$

Use Evaluate[y[x] /. s[[1]]] instead of Evaluate[y[x] /. s] to get

enter image description here

$\endgroup$

Your Answer

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

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