%
% rc1.m    rc, 1 compartment
%
close all
% root
R = [0 0; 1 0; 1.2 .25; 1.6 -.25; 2 .25; 2.4 -.25; 2.6 0; 3.6 0];
R = R';
r = max(R(1,:));     % length of a resistor
C1 = [0 0; 0 -r/2+.15; .5  -r/2+.15; -.5 -r/2+.15];
C2 = [0 -r; 0 -r/2-.15; .5  -r/2-.15; -.5 -r/2-.15];

a = [0 0; r/2 0; r/2-r/6 .1; r/2 0; r/2-r/6 -.1];
a = a';

plot([0 r],[0 0],'k','linewidth',1.5)
hold on
text(r,0.25,'x','fontsize',14)

text(r-1.1,-r/2,'y_1','fontsize',14)
text(r+.4,-r/2,'R_m','fontsize',14)

text(2*r-1.15,-r/2,'y_2','fontsize',14)
text(2*r+.25,-r/2+.5,'C_m','fontsize',14)

rot = [0 1;-1 0];
V = rot*R;
d = rot*a;   % down arrow
plot([0 0],[0 1/sqrt(2)-r/2],'k','linewidth',1.5)
plot([0 0],[-1/sqrt(2)-r/2 -r],'k','linewidth',1.5)
t = 0:.01:2*pi;
plot(cos(t)/sqrt(2),sin(t)/sqrt(2)-r/2,'k','linewidth',1.5)
text(-.2,-r/2-.1,'i_0','fontsize',14)
plot(r+V(1,:),V(2,:),'k','linewidth',1.5)
plot(d(1,:)+r-0.5,d(2,:)-r/4,'k','linewidth',1)
G = [-.2 0; .2 0; 0 -.2; -.2 0];
G = G';
plot(G(1,:),G(2,:)-r,'k','linewidth',1.5)
plot(G(1,:)+r,G(2,:)-r,'k','linewidth',1.5)

plot([r 2*r],[0 0],'k','linewidth',1.5)

 %plot(V(1,:)+2*r,V(2,:),'k','linewidth',1.5)
plot(C1(:,1)+2*r,C1(:,2),'k','linewidth',1.5)
plot(C2(:,1)+2*r,C2(:,2),'k','linewidth',1.5)
plot(d(1,:)+2*r-0.75,d(2,:)-r/4,'k','linewidth',1)
 plot(G(1,:)+2*r,G(2,:)-r,'k','linewidth',1.5)

axis equal
%grid on
%ylim([-4 1])
axis off




