function circuit
% Data for Chua's oscillator
% ___________________________________________________________
nc = 3; % number of contours: 1, 2, 3, 4.
rv = 1; % ordinal number(s) of vert edge(s) (resistor)
rh = [1,2]; % index(es) of horz edge(s): row, col
cv = [2,3]; % ordinal number(s) of vert edge(s) (capacitor)
ch = 0; % index(es) of horz edge(s): row, col
iv = 1; % ordinal number(s) of vert edge(s) (inductor)
ih = 0; % index(es) of horz edge(s): row, col
uv = 4; % ordinal number(s) of vert edge(s) (Chua)
% ___________________________________________________________
% For universal Chua's circuit delete percentage sign below:
% iv = 0; ih = [1,2];
ar = 1.75; % aspect ratio, horz./vert.
% aspect ratio dependent coefficients:
cm = ar/20;
cm1 = ar/100;
k = ar/40;
s2 = ar/10;
sh = cm1*nc;
ws =.3*ar/1.8;
x = (0:7)'*cm1; % resistor
y = [0; 1.1; - 1.1; 1.1; - 1.1; 1.1; - 1.1; 0]*ar*cm1;
z = -.8572:0.0002:0.5717; % inductor
t = (z+1)*pi*3.5;
v = 2*cos(t)'*cm1;
u = ((z + 0.35*(-sin(t) + 1))/17 + .75)';
ux = [-2.75; -2.75; 8; 8; -2.75]*cm1; % Chua's device
uy = [-1.45; 1.45; 1.45; -1.45; -1.45]*ar*cm1;
ux1=ux/5 - max(uy) + max(y);
ca = [.5,0; .5,1; 1,1; 1,0]; % capacitor
d(nc+1)=0; % memory allocation
for j = 1:nc + 1
d(j) = ar/nc*(j-1);
end
q = '123456789'; % indices
fz = 'fontsize'; % property name
fs = 13; % property value
b = [0,1; 1,0]; % rotation
contr(nc,ar) % drawing contours
for j = cv(cv>0) % capacitors on vertical edges
s = [4, - .5 + d(j)/cm];
s1 = s(1)*cm;
c = (ca + s)*cm; % capacitor
mm = max(c(3:4,:) - c(1:2,:));
w = [d(j),mm(1); d(j),mm(2)] + [s1,0;s1,0]*b;
cr(1,w,c*b,0,0)
text(d(j) - .17, c(2,1) + .025,['C_',q(j)],fz,fs)
end
for j = 1:2:numel(ch)*all(ch) % capacitors on horizontal edges
aa = ar /nc*(ch(j + 1) - 1);
ac = cm/nc*(j - 1);
s = [4 + aa/cm, - .5];
s1 = s(1)*cm - ac;
c = ([.5,0; .5,1; 1,1; 1,0] + s)*cm; % capacitor
mm = max(c(3:4,:) - c(1:2,:)) + ac;
w = [0,mm(1); 0,mm(2)]*b + [s1,0; s1,0];
cr(1,w,c,2 - ch(j),sh)
text(c(1,1) - .1, c(1,2) + 2.16 - ch(j),...
['C_',q(ch(j)),'_,_',q(ch(j+1))],fz,fs)
end
uu=[rv,uv];
for j = uu(uu>0) % resistors on vertical edges
w = [s2,d(j); s2 + max(x),d(j)]*b;
c = [x,y]*b + [d(j),s2]; % resistor
cr(0,w,c,0,0)
if j <= numel(rv)
text(c(1,1) - .16, c(1,2) + .075,['R_',q(j)],fz,fs)
end
end
for j = 1:2:numel(rh)*all(rh) % resistors on horizontal edges
aa = ar/nc*(rh(j + 1) - 1);
w = [s2 + aa,0; s2 + max(x) + aa,0];
c = [x,y] + [0,s2 + aa]*b; % resistor
cr(0,w,c,2 - rh(j),sh)
text(c(1,1) - .1, c(1,2) + 2.125 - rh(j),...
['R_',q(rh(j)),'_,_',q(rh(j+1))],fz,fs)
end
for j = iv(iv>0) % inductors on vertical edges
w = [.6996,d(j); .789 + max(v),d(j)]*b;
c = [v,u] + [d(j),0]; % inductor
cr(0,w,c,0,0)
text(c(1,1) - .16, c(1,2) + .075,['L_',q(j)],fz,fs)
end
for j = 1:2:numel(ih)*all(ih) % inductors on horizontal edges
aa = ar/nc*(ih(j + 1) - 1);
w = [s2 + aa + ws, 0; s2 + range(u) + aa + ws, 0];
c = [(u - min(u))*max(x)/range(u)*1.8/ar ...
+ ws, -v] + [0, s2 + aa]*b; % inductor
cr(0,w,c,2 - ih(j),sh)
text(c(1,1) - .05, c(1,2 ) + 2.125 - ih(j),...
['L_',[q(ih(j)),'_,_',q(ih(j+1))]],fz,fs)
end
for j = uv(uv>0) % Chua device on vertical edges
c = [ux,uy]*b + [d(j),s2];
c1 = [ux1,uy]*b + [d(j),0.14];
k1 = c(2,1) + k;
text([k1, k1, k1], [c(1,2) - k, c(2,2) + 5*k, c(2,2) + 2*k]...
,{'+','-','N_R'},fz,fs)
plot(c(:,1),c(:,2),'b')
fill(c1(:,1),c1(:,2),'b')
end
set(gcf,'color','w')
axis off
hold off
end
function cr(f,w,c,vh,sh)
plot(w(:,1) - sh,w(:,2) + vh,'w')
switch f
case 0
plot(c(:,1) - sh,c(:,2) + vh,'b')
case 1
plot(c(1:2,1) - sh,c(1:2,2) + vh,'b',...
c(3:4,1) - sh,c(3:4,2) + vh,'b')
end
end
function contr(nc,sz)
yr = [0,0,1,1,0]; % contour (rectangle)
xr = [0,sz,sz,0,0];
plot(xr,yr,'b');
axis([ -.1*sz, sz*1.05, -.1*sz, 1.1], 'equal');
hold on
for i = 2:nc % internal vertical edges
plot([sz,sz]/nc*(i - 1),[0,1],'b.-','markersize',12);
end
end