A complete tutorial on this Electric Circuits in the Answer is impossible. It is advisable to read a standard textbook on electric circuits to gain a better understanding of the practical aspects of these systems. Some professors and textbooks provide guidance on how to mathematically model electric circuits, but they may not teach you how to implement these models in code or simulations, likely because this is not part of the curriculum. Here is a cimple demo in MATLAB:
%% RLC Circuit
function dx = RLCcircuit(t, x)
R = 20; % Resistance, unit: ohm (Ω)
L = 300e-3; % Inductance, unit: henry (H)
C = 50e-6; % Capacitor, unit: farad (F)
Vi = 100; % Input Voltage, unit: volt (V)
% differential equations
dx = zeros(2, 1);
dx(1) = -R/L*x(1) - 1/L*x(2) + 1/L*Vi;
dx(2) = 1/C*x(1) + 0*x(2) + 0*Vi;
end
%% run simulation
tspan = linspace(0, 0.2, 2001);
x0 = [0; 0];
[t, x] = ode45(@RLCcircuit, tspan, x0);
% current flows through the inductor
I = x(:,1);
% voltage across the capacitor
V = x(:,2);
%% measurements
tp = 0.03; % particular time
idx = find(t == tp)
Itp = I(idx)
Vtp = V(idx)
%% plot results
tl = tiledlayout(2, 1, 'TileSpacing', 'Compact');
nexttile
hold on
plot(t, I), grid on
plot(tp, Itp, 'o')
hold off
ylabel('I(t)')
title('Current flows through the inductor')
nexttile
hold on
plot(t, V), grid on
plot(tp, Vtp, 'o')
hold off
ylabel('V(t)')
title('Voltage across the capacitor')
xlabel(tl, 't')
While you can graphically model electric circuits using Simscape Electrical, most professors typically demonstrate how to model circuits using PSpice (commercial) or LTspice (free), as these are considered the gold standards for circuit design and simulation. However, these graphical models of electric circuits do not inherently show the necessary math for analysis. Only textbooks will provide this information, as the math elements are often integrated into the functions, graphical blocks, and components within the software.
