function g=diodoChuareal(v)
R1 = 220;
R2 = 220;
R3 = 2200;
R4 = 22000;
R5 = 22000;
R6 = 3300;

Esat = 9; %9V batteries
E1 = R3/(R2+R3)*Esat;
E2 = R6/(R5+R6)*Esat;

m12 = -1/R6;
m02 = 1/R4;
m01 = 1/R1;
m11 = -1/R3;

m1 = m12+m11;

if(E1>E2)
m0 = m11 + m02;
else
m0 = m12 + m01;   
end

mm1 = m01 + m02;
Emax = max([E1 E2]);
Emin = min([E1 E2]);
if abs(v) < Emin
   g = v*m1;     
elseif abs(v) < Emax 
    g = v*m0;
    if v > 0
    g = g + Emin*(m1-m0);    
    else
    g = g + Emin*(m0-m1);  
    end
    
elseif abs(v) >= Emax
    g = v*mm1;    
    if v > 0
        g = g + Emax*(m0-mm1) + Emin*(m1-m0);
    else
        g = g + Emax*(mm1-m0) +  Emin*(m0-m1);
    end
end