Effacer les filtres
Effacer les filtres

solving rlc circuit using ode45

26 vues (au cours des 30 derniers jours)
sami alzeq
sami alzeq le 8 Août 2018
Commenté : sami alzeq le 9 Août 2018
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 commentaires
James Tursa
James Tursa le 8 Août 2018
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 le 9 Août 2018
thanks

Connectez-vous pour commenter.

Réponse acceptée

Aquatris
Aquatris le 9 Août 2018
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?

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by