signals with just one Matlab script. The script CNRL.m models a series RL circuit as shown in figure 1. Fig. 1. RC circuit with the script CNRL.m The response of the circuit to an input signal is calculated using Kirchhoff’s Voltage and Current Laws and using the finite difference approximation for the voltage across the inductor The finite difference method to analyse the RL circuit is done in the following sequence of steps. Step 1: Specify the input source voltage as a function of time. This is done within the switch/case statements using the variable flagV. FlagV = 4 gives a sinusoidal source emf expressed as a complex function. Using complex functions makes it possible to calculate the magnitude, real part, imaginary part and phase of a complex variable. % Source emf: flagV = 1 step function off/on % flagV = 2 step function on/off % flagV = 3 pulses (square wave) % flagV = 4 sinusoidal emf
signals with just one Matlab script. The script CNRL.m models a series RL circuit as shown in figure 1. Fig. 1. RC circuit with the script CNRL.m The response of the circuit to an input signal is calculated using Kirchhoff’s Voltage and Current Laws and using the finite difference approximation for the voltage across the inductor The finite difference method to analyse the RL circuit is done in the following sequence of steps. Step 1: Specify the input source voltage as a function of time. This is done within the switch/case statements using the variable flagV. FlagV = 4 gives a sinusoidal source emf expressed as a complex function. Using complex functions makes it possible to calculate the magnitude, real part, imaginary part and phase of a complex variable. % Source emf: flagV = 1 step function off/on % flagV = 2 step function on/off % flagV = 3 pulses (square wave) % flagV = 4 sinusoidal emf