clear all
global R L C E Iin eps R1 R2 I1 I2 aa

R=0.1; L=1; C=.02; E=0.2; Iin=0; eps=.001;
% R--resistance, L--inductance, C--capacitance, E--battery
% Decreasing C to increase the number of spikes
% Increase Iin to suppress the spike bursts. 

% Resistor 1 parameters
R1=2;R2=-3;I1=1;I2=2;

% Resistor 2 parameter
aa=-1;

%
% Plot the IV-characteristics for resistor 1 and 2
%
figure(1)
hold off
clear I V
I=-0.5:.1:4;
V=-1:.1:4;
%plot(r(I),I,'r-')
plot(r(I),I,'r-',V,g(V),'b-')
legend('Resistor 1','Resistor 2')


T=1;
% Numerical solutions
[t,x]=ode15s('SB',[0,5],[1;1;1]);
figure(2)
hold off
N=find(t>T); % Skip the first period of forcing
plot(t(N:end),x(N:end,1),'r-',t(N:end),x(N:end,2),'b-',t(N:end),x(N:end,3),'g-')
hold on
legend('V_C','I_L','I_g')

figure(3)
hold off
plot3(x(N:end,1),x(N:end,2),x(N:end,3),'r-')
hold on

