% This script plots a general circuit with % inductance L, resistor R, capacitor C, and switch S. hold on % plotting the frame of the circuit: plot_line([1.5,0],[1,0.5]); plot_line([1.5,0],[2,0.5]); plot_line([0,1.5],[0.5,1]); plot_line([0,1.5],[0.5,2]); plot_line([1.5,3],[1,2.5]); plot_line([1.5,3],[2,2.5]); plot_line([3,1.5],[2.5,2]); plot_line([3,1.5],[2.5,1]); % plotting switch, capacitor, inductor, resistor plot_switch(0.6,1.2,[2,0.5],[2.5,1]); plot_capacitor(0.1,0.4,[0.5,1],[1,0.5]) plot_inductor(5,0.4,[0.5,2],[1,2.5]) plot_resistor(5,0.4,[2,2.5],[2.5,2]) % put the marking labels text(0.5,3,'L'); text(2.5,3,'R'); text(2.5,0,'S'); text(0.5,0,'C'); title('circuit with inductance L, resistor R, capacitor C, and switch S'); % final axis axis([-1 4 -1 4]) hold off