function [x]=wheatstone(r3,r4);

%wheatstone(r3,r4) takes input values for resistors 3 and 4 and plots the
%current vs. r2 assuming that V=6 volts, and r1=1 ohm and rA=.001 ohms.

%Hardwired values for r1, the ammeter resitance and the source voltage
r1=1;
rA=0.001;
V=6;


r2=(0:.05:100);

%expression for current vs. resistance of r2
y=([V.*(r2.*r3-r1*r4)]./[r2.*(rA*r1+rA*r3+r1*r3+r4*r1+r4*r3)+rA*r3*r4+rA*r1*r4+r1*r3*r4]);

%expression for change in current vs change in resistance
der=((([V*((1+10^-12)*r3-r1*r4)]/[(1+10^-12)*(rA*r1+rA*r3+r1*r3+r4*r1+r4*r3)+rA*r3*r4+rA*r1*r4+r1*r3*r4])-([V*((1-10^-12)*r3-r1*r4)]/[(1*10^-12)*(rA*r1+rA*r3+r1*r3+r4*r1+r4*r3)+rA*r3*r4+rA*r1*r4+r1*r3*r4]))/(2*10^-12))


figure;cla;
plot(r2,y);
axis([0 20 -1/r3 1/r3]);
xlabel('Resistance of r2 (ohms)'); ylabel('Current through ammeter (A)');
title('Current vs. Resistance for Wheatstone bridge');
text(10,0,'r3=r4=');text(12,0,num2str(r3));