Clear Filters
Clear Filters

Calculating Capacitor Current using i= C* dv/dt

38 views (last 30 days)
Gary
Gary on 21 Jun 2023
Answered: Deepak on 21 Jun 2023
I would like to use Matlab to calculate capaitor current for the following
i = C * dV/dt
i = 0.2uF * 12V/dt
128kHz frequncy

Answers (1)

Deepak
Deepak on 21 Jun 2023
Hey @Gary,
To calculate the capacitor current for the given circuit, you can use MATLAB's symbolic math toolbox to evaluate the expression for the capacitor current as a function of time.
Sample code to calculate the capacitor current for a 0.2uF capacitor, with a voltage input of 12V at a frequency of 128kHz is given below.
syms t;
C = 0.2e-6; % capacitance in Farads
V = 12; % voltage in volts
f = 128e3; % frequency in Hertz
w = 2*pi*f; % angular frequency in radians per second
i = C*diff(V*sin(w*t), t); % evaluate the capacitor current using symbolic differentiation
This creates a symbolic expression for the capacitor current as a function of time. In this example, the input voltage is a sine wave; you could use different input waveforms as needed by replacing the `V*sin(w*t)` term with a different function.
Once the symbolic expression is created, you can plot the capacitor current as a function of time using the `ezplot` function. For example:
ezplot(i, [0, 1/f]); % plot the capacitor current for one cycle of the input waveform
title('Capacitor Current vs Time');
xlabel('Time (s)');
ylabel('Current (A)');
This would create a plot showing the capacitor current as a function of time, for one cycle of the input waveform. You can adjust the plot range or add additional features as needed.

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!