solving rlc circuit using ode45

조회 수: 15 (최근 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 CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by