RLC Circuit Equation Implementation-Runge Kutta

7 ビュー (過去 30 日間)
OvercookedRamen
OvercookedRamen 2019 年 11 月 12 日
コメント済み: darova 2019 年 11 月 20 日
Hello, I need to convert an RLC equation to work inside the functions I have wirtten. Currently MatLab is telling me there are too many variables inside my equation for it to work. Here is the code of the function I am trying to work with
function [derriv_value] = RLC(y)
%Function that contains the derrivative value
%RLC Implementation: The equation is given by L*Q'' + R*Q' + (1/C)*Q = E(t)
% E(t) is the sum of total voltage drop across the circuit.
% R is resistance, L is indunctance, and C is capacitance. Q Is the charge
% in coloumbs. This equation is currently in a second order form.
% In most cases, the voltage in the system is known, it is usually the
% current (I) that is unknown.
% If we differentiate both sides and subsitute Q for I, we get,
% L*I'' + R*I' + (1/C)*I = E'(t)
% Since this is the more pratical case, we will use this format.
% Here are some values that could be used to simulate this.
% These above are some example values.
R = 10; % Resistance (Series RL Branch), Ohms..
L = 100e-3; % Inductance (Series RL Branch), H..
C = 50e-6; % Capacitor (Series RLC Branch), F
derriv_value = L*y(3)+R*y(2)+(1/C)*y;
end
And this function will be called in a Runge Kutta implementation file. I'll attach it. I have another file called FunctionC that has a format that matlab accepts. It works with the Runge Kutta file.
  2 件のコメント
darova
darova 2019 年 11 月 12 日
Read this
OvercookedRamen
OvercookedRamen 2019 年 11 月 12 日
Yeah I already looked over that. I have the equation converted fine on paper, the issue is trying to set up a system of 3 first order ODEs in a format that will run like the equation in FunctionC.

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

採用された回答

Daniel M
Daniel M 2019 年 11 月 12 日
Instead of this
derriv_value = L*y(3)+R*y(2)+(1/C)*y;
Do you mean this?
derriv_value = L*y(3)+R*y(2)+(1/C)*y(1);
  9 件のコメント
OvercookedRamen
OvercookedRamen 2019 年 11 月 20 日
How would you get this equation into a system of 3 first order ODEs?
darova
darova 2019 年 11 月 20 日
Your equation is of second order
% L*Q'' + R*Q' + (1/C)*Q = E(t)
% Q'' = 1/L*( E(t) - R*Q' - Q/C );
f = @(t,y) [y(2)
1/L*(E - R*y(2) - y(1)/C)];
[t,y] = ode45(f,ts,y0);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by