Group Abstract Group Abstract

Message Boards Message Boards

[?] Solve a piecewise function with NDSolve?

Posted 8 years ago
3 Replies

You haven't formatted your code correctly, so it cannot be copied, pasted and tested.

However, try {v[t], p[t]}, i.e., putting the expressions to solve for in a list, in NDSolve instead of NDSolve[..., v[t], p[t], {t, 0, 100}].

POSTED BY: Michael Rogers

Thanks for your comment. I have also tried this but it did not work neither. How can I format the the code ? I am new on this site.

Just insert brackets around the unknown functions, and a replacement of parameters:

NDSolve[{v'[
     t] == (r v[t] - (price b v[t])/
       Piecewise[{{z'[p[t]], pbar > p[t]}, {pbar, pbar < p[t]}}]) /. 
   paramFinal, 
  p'[t] == Piecewise[{{-((p[t] z'[p[t]])/z''[p[t]]) - a v[t] /. 
        paramFinal, pbar > p[t]}, {0, pbar < p[t]}}] /. paramFinal, 
  v[0] == 0.024, p[0] == 0.025}, {v[t], p[t]}, {t, 0, 100}]
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