% Voltage Divider Circuit for Finding Unknown Resistance
% Written for Smart Lighting Summer High School Programs
% K. A. Connor, June 2015

% Voltage Source (Volts)
Vb=9;

% Known Resistance Values (Ohms)
R(1)=1;R(2)=1000;R(3)=4700;R(4)=10000;R(5)=47000;R(6)=1e9;

% Unknown Resistor (Ohms)
Ru=13000;

% Calculate Normalized Voltages Across R Unknown (Vu Divided by Vb)
for i=1:6;Vu(i)=Vb*Ru/(Ru+R(i));Vn(i)=Vu(i)/Vb;end;

% Calcultate the Current Drawn from the Battery (Amps)
for i=1:6;Ib(i)=(Vb-Vu(i))/R(i);end;

% Plot I-V 
plot(Vu,Ib,'o');grid;xlabel('Volts');ylabel('Amps');hold on;plot(Vu,Ib,'r');

