admin管理员组文章数量:1293316
Problem: Use MATLAB's symbolic toolbox to find the general and particular solution for the transient response of i(t) in a simple/canonical RLC circuit.
Challenge: Execution of the line iSol(t) = dsolve(eqn, [cond1, cond2]);
in the code below raises an error that states that the solver is unable to reduce the square system because the number of equations differes from the number of indeterminates. Can someone help me resolve this issue?
Code
syms i(t) R L C V0
% Define component values
R = 10;
L = 1;
C = 1;
V0 = 12;
% Define the differential equation
eqn = L*diff(i(t), t, 2) + R*diff(i(t), t) + (1/C)*i(t) == 0;
% Define initial conditions
cond1 = i(0) == 0; % i(0) = 0
cond2 = diff(i(t),t) == V0/L; % di/dt(0) = V0/L
% Solve the differential equation with initial conditions
iSol(t) = dsolve(eqn, [cond1, cond2]);
% Display the particular solution
disp('Particular Solution for i(t):')
disp(iSol(t))
Problem: Use MATLAB's symbolic toolbox to find the general and particular solution for the transient response of i(t) in a simple/canonical RLC circuit.
Challenge: Execution of the line iSol(t) = dsolve(eqn, [cond1, cond2]);
in the code below raises an error that states that the solver is unable to reduce the square system because the number of equations differes from the number of indeterminates. Can someone help me resolve this issue?
Code
syms i(t) R L C V0
% Define component values
R = 10;
L = 1;
C = 1;
V0 = 12;
% Define the differential equation
eqn = L*diff(i(t), t, 2) + R*diff(i(t), t) + (1/C)*i(t) == 0;
% Define initial conditions
cond1 = i(0) == 0; % i(0) = 0
cond2 = diff(i(t),t) == V0/L; % di/dt(0) = V0/L
% Solve the differential equation with initial conditions
iSol(t) = dsolve(eqn, [cond1, cond2]);
% Display the particular solution
disp('Particular Solution for i(t):')
disp(iSol(t))
Share
edited Feb 13 at 5:32
Cris Luengo
60.8k10 gold badges73 silver badges129 bronze badges
asked Feb 12 at 21:29
BP130BP130
675 bronze badges
2
|
1 Answer
Reset to default 2You directly have an example in the documentation of a second order equation with initial conditions on the unknown function and its derivative.
Applying it to your problem gives:
syms i(t) R L C V0
% Define component values
R = 10;
L = 1;
C = 1;
V0 = 12;
% Define the differential equation
eqn = L*diff(i, t, 2) + R*diff(i, t) + (1/C)*i == 0;
% Define initial conditions
Di = diff(i,t);
init_cond = [i(0)==0, Di(0)==V0/L];
% Solve the differential equation with initial conditions
iSol(t) = dsolve(eqn, init_cond);
% Display the particular solution
disp('Particular Solution for i(t):')
disp(iSol(t))
Edit: I have called the unknown i
, like you did, but it is good practice not to use i
(or j
) as variable names in Matlab.
Edit 2: It seems like the variable in the differential equation governing the behavior of a RLC circuit should be the charge q
instead of the current i
. Nonetheless the equation is right (if solving for the charge)
本文标签: Solving Differential Equations in MATLAB39s Symbolic Math ToolboxStack Overflow
版权声明:本文标题:Solving Differential Equations in MATLAB's Symbolic Math Toolbox - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741575779a2386274.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
diff(i(t),t) == V0/L
does not say that the derivative is that value at t=0. It makes the derivative constant. But I don’t know how to do this right, I have very little experience with this toolbox. – Cris Luengo Commented Feb 13 at 1:02R
,L
,C
, andV0
as double values wipes the previously defined symbolic variables of the same names. Justsyms i(t)
is needed in your first line. – horchler Commented Feb 18 at 18:58