% Write a Live Script to calculate the current through and voltage across a resistor, capacitor, and inductor in parallel and their total impedance.  First complete two functions to calculate the reactance of a capacitor and inductor.  The components are in parallel and the voltage and its phase are constant for each element. Using this information, we can calculate the current through each component.  Complete the next three function to calculate the current in each branch.  Finally, calculate the total impedance by dividing the voltage by the current using their phaser representation.
%

%This is the script part of the Live Script
V = 9;
R = 0.1;
C = 2.e-6;
L = 0.2e-3;
f = 800:100:5000;
Xc = CReactance(f,C);
XL = LReactance(f,L);
IR= Rcurrent(V,R);
[IC,phaseC] = Ccurrent(V,Xc)
[IL,phaseL] = Lcurrent(V,XL)
plot(f,IC,'r',f,IL,'b')

%
% Below are the five functions we use in the script above.
%

function Xc = CReactance(??,??)
    Xc = 1./(??*??*??*??);
end

%

function XL = LReactance(?,?)
    XL = ??*??*??*??;
end

%

function IR = Rcurrent(??,??)
    IR = ??/??;
end

%

function [IC,phaseC] = Ccurrent(??,??)
    IC = ??./??;
    phaseC = 0-(??);
end

%

function [IL,phaseL] = Lcurrent(??,??)
    IL = ??./??;
    phaseL = 0-(??);
end

%

function [Zp, phaseP] = total_imp(V,IL,IC,IR)
    Zimag = IC-IL;
    Zp = sqrt(R^2+Zimag^2);
    phaseP = arctan(Zimag/Zp);
end