function V = K(I)
global r1 r2 i1 i2
% 
% Two resistors in series to generate the `S' IV-characteristics (for the
% K-channel)
% 
%
k1=r1*I; % serial resistor 1
k2=(I>i1).*(I<=i2).*((-r1+r2).*(I-i1))+(I>i2).*((-r1+r2)*(i2-i1)); % serial resistor 2
V = k1 + k2;% equivalent resistor by Kirchhoff's Laws.

