solving rlc circuit using ode45

19 ビュー (過去 30 日間)
sami alzeq
sami alzeq 2018 年 8 月 8 日
コメント済み: sami alzeq 2018 年 8 月 9 日
i have homework to solve rlc circuit using ode45 i tried this code and the question is how to plot Vl1 anyone can help me please and if there is any mistake in this code
function RLC=homework(t,x)
R1=20;R2=30;L1=4*10^-3;L2=2*10^-3;C=0.004;u=100;
RLC(1)=(R1/L1)*(x(1))+(1/L1)*(x(2))-(1/L1)*u;
RLC(2)=-(R2/L2)*(x(2))+(1/L2)*(x(3));
RLC(3)=(-1/C)*(x(1))-(1/C)*(x(2));
RLC=RLC';
[t,x]=ode45('homework',[0 10],[2;2;2]);
  2 件のコメント
James Tursa
James Tursa 2018 年 8 月 8 日
You are missing a minus sign on the first rhs term on the x1dot line:
RLC(1) = -(R1/L1)*(x(1)) + (1/L1)*(x(2)) - (1/L1)*u;
sami alzeq
sami alzeq 2018 年 8 月 9 日
thanks

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

採用された回答

Aquatris
Aquatris 2018 年 8 月 9 日
If you were to use the code;
[t,y] = ode45(@homework,t,[0 0 0]');
the y here is your i1, i2, and vc.
From here you should know how to get desired Voltages (Kirschof law etc.).
The subplot command will be used as;
subplot(4,1,1),plot(t,Vl1) % "subplot(4,1,2)" means there will be
subplot(4,1,2),plot(t,Vr2) % 4 rows and 1 column in total for
subplot(4,1,3),plot(t,Vr1) % the plots and this one is the 2nd
subplot(4,1,4),plot(t,Vc) % plot
Similar thing for the currents.
In part 4, you just need to replace u in the function with the sine wave.
Is there any particular question you have other than these?

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by