How do i write this differential equation in matlab?
1 回表示 (過去 30 日間)
古いコメントを表示
Augustine Nashwan Aziz Al-Zebary
2021 年 5 月 12 日
コメント済み: Star Strider
2021 年 5 月 13 日
global R C u
R = 10e3;
C = 3.3e-6;
tau = R*C;
u = @(t) 10*(t>tau);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/616070/image.png)
The initial value is uC(0)=0
I want to write the diff equation in a function and use ode45 to solve it. Can someone please help me? i've tried everything but i dont understand how to write it into a function and how to solve it. Would be really appreciated!
0 件のコメント
採用された回答
Star Strider
2021 年 5 月 12 日
There are several options, including using the numerical solvers.
This approach uses the Symbolic Math Toolbox —
syms C R uc(t) u
eqn = R*C*diff(uc)+uc == u;
uc(t) = dsolve(eqn, uc(0)==0)
uc = subs(uc,{C,R,u},{1E-9,1E+3,sin(2*pi*t)})
figure
fplot(uc, [0 10])
grid
.
5 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!