Message Boards Message Boards

0
|
10339 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How to add "If" conditions for higher ordinary differential equations ?

Posted 9 years ago

enter image description here

Hi, guys I have a problem here on how should I add a condition for variable "A" as shown in the image highlighted in red under equation 4 (eq4). The condition I would like to set is that "A" equals "(b/m)p'[t] + (k/m)(p[t]-0.5) when "(p[t] >= l/2)" and "A" equals to zero when "(p[t] < l/2)" .

Any advise or changes I should make to the coding ? I truly appreciate your help here. Cheers.

Best regards, Aaron Aw`

POSTED BY: Aaron Aw
5 Replies

Umm, the idea is that you should try the suggestion. You didn't. You instead provided a notebook that won't run the NDSolve, and fails for a very obvious reason. A bit of debugging before posting is always a good idea.

POSTED BY: Daniel Lichtblau

Could write it in terms of Piecewise.

POSTED BY: Daniel Lichtblau
Posted 9 years ago

Hmmm, not sure bout that but, here's the file attached regarding my problem. Hopefully you can help me out. Thanks a lot.

Attachments:
POSTED BY: Aaron Aw
Posted 9 years ago

Have you considered using a WhenEvent? I had a similar problem once myself. Check out the docs as well. It would be nice if you posted the code so one can copy it at run it easily instead of screenshoting it.

POSTED BY: Julian Lovlie
Posted 9 years ago

thanks man, but I still can't get it using "While" though the site on doc recommended was helpful. Anyway I've attached the nb. file and hopefully and you can test it out. I appreciate your help very much.

Best regards, Aaron Aw

Attachments:
POSTED BY: Aaron Aw
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