% Solution to Example 2.7

clc             % clear the command window
clear           % clear all variables
close all       % close any existing windows
format compact	% prevent extra blank lines in the output

Vin = 5*exp(1i*pi/2)
mag_Vin = abs(Vin)
arg_Vin = angle(Vin)*180/pi

w = 3000;
R1 = 1000;
R2 = 3000;
L = 0.5;
C = 0.2*10^-6;

ZL = 1i*w*L
ZC = 1 / (1i*w*C)

Zeq = R1 + (R2+ZL)*ZC/((R2+ZL) + ZC)
mag_Zeq = abs(Zeq)
arg_Zeq = angle(Zeq)*180/pi

I1 = Vin/Zeq
mag_I1 = abs(I1)
arg_I1 = angle(I1)*180/pi

I = (R2+ZL)/((R2+ZL) + ZC) * I1
mag_I = abs(I)
arg_I = angle(I)

format short;
display (' ');
display ([num2str(mag_I*1000) 'I(t) = cos(' num2str(w) 't + ' num2str(arg_I) ') mA']);


