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 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:02
  • Your defining of R, L, C, and V0 as double values wipes the previously defined symbolic variables of the same names. Just syms i(t) is needed in your first line. – horchler Commented Feb 18 at 18:58
Add a comment  | 

1 Answer 1

Reset to default 2

You 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