188
Practical MATLAB
® Applications for Engineers
ANALYTICAL Solution
The loop differential equation is given by
V
di t
dt
i t
t
1
20
2
0
ϭ
ϭ
ϩ
Ն
V
f o r
( )
( )
with
A and
A
i
i
( )
( )
0
10
2
5
20
2
10
ϭ
ϭ
ϭ
ϭ
ϱ
Assuming a solution for i(t) of the form i(t) = A + Be
−t/τ
, where τ = L/R = 0.5 s, and by
using the initial and fi nal current conditions, the constants A and B can be evaluated.
By following this process the current is then i(t) = 10 − 5e
−2t A, and the corresponding
voltages are v R (t) = 20 − 10e
−2t V and v L (t) = 10e
−2t V, for t ≥ 0.
MATLAB Solution
% Script file: RC _ IC
syms t;
% symbolic solution
it _ 1 = dsolve(‘Dy+2*y=20’,’y(0)=5’,’t’);
disp(‘*****************************************’);
figure(1)
subplot(3,1,1);
ezplot (it _ 1,[0 2]);ylabel(‘i(t) in amps’);
title(‘plots of: [i(t), vr(t) and vL(t)] vs t’);
subplot(3,1,2);
vtr _ 1 = it _ 1*2;
ezplot(vtr _ 1,[0 2]);ylabel(‘vr(t)’);title(‘
‘);
subplot (3,1,3);
vl _ 1 = 20-vtr _ 1;
ezplot (vl _ 1,[0 2]);ylabel(‘vL(t)’);title(‘
‘);
xlabel (‘time in sec.’);
disp(‘**********R E S U L T S ****************’);
disp(‘*****************************************’);
disp(‘The i(t) for t >0 is:’);
it _ 1
disp(‘The voltage across R=2 ohms is :’)
vtr _ 1
disp(‘The voltage across L=1 henry is :’)
vl _ 1
disp(‘********Verify solution******************’);
echo on
disp(‘******************************************’)
verify = diff(it _ 1,t)+2*it _ 1
echo off
% numerical solution
clear;
% solution using ode45
t0 = 0;R=2;
tf = 2;
ts = [t0 tf];
i0 = 5; % initil cond.
t =linspace(0,2,100);
[t,it] = ode45(‘f’,ts,i0);
CRC_47760_CH002.indd 188
CRC_47760_CH002.indd 188
7/23/2008 1:38:57 PM
7/23/2008 1:38:57 PM
Précédent

- 199/708

Suivant