# How to numerically solve a differential equation with a dirac delta function ?

48 ビュー (過去 30 日間)
Mohit Kumar 2020 年 6 月 30 日
コメント済み: Mohit Kumar 2020 年 7 月 13 日
The differential equation that I want to solve is
Upon using ode45 and the dirac function, the dirac function doesn't seem to have any effect (which makes sense because x never reaches 1 in a numerical solution)
Any ideas on how to solve this numerically?
##### 6 件のコメント表示非表示 5 件の古いコメント
Alan Stevens 2020 年 7 月 1 日

Hmm. I assumed you just wanted the dxdt - |dxdt| to kick in when x = 1 (The area under the delta function being unity). I'm not sure what you are after if you truly want it to go to infnity (what do you expect the ode function to do with that?). Indeed, if infinity is what you want why bother multiplying it by anything else?

サインインしてコメントする。

### 採用された回答

Walter Roberson 2020 年 7 月 1 日
Use ode45 to solve the equation over the start time to time 1 (the place the dirac delta is located.) Do not use the if statements like Alan and Mohit show: just end the integration at the point they would take effect. Using if presents theory problems that you can avoid by just stopping at the place of the event.
Now take the final output of that ode45 and give the appropriate kick to the boundary conditions.
Then restart the ode45 from time 1 to the final desired time, passing in the kicked boundary conditions. Do not use if -- again you avoid the theory problem by not having ode45 cross the interval of discontinuity.
##### 11 件のコメント表示非表示 10 件の古いコメント
Mohit Kumar 2020 年 7 月 13 日
Ah right, my proof is definitely fallacious. I got carried away trying to contrive the derivation!
Your derivation is nice and concise! Thanks for all the help! Glad to have learnt (although superficially) a hitherto alien concept of the dirac delta function in the context of differential equations.

サインインしてコメントする。

### カテゴリ

Find more on Assembly in Help Center and File Exchange

R2020a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by