0

I have an equation given by the formula. Its actually charge a variable capacitor given by the following relation.

*q=c(v)dv...........Equation (1)

c(v) is a function of v and v is just s sine wave defined in matlab as under.

t = 0:0.01:5;
f=0.2;
v = 5*sin(2*pi*f*t);

c(v) can be any function dependent of v.

What I want to do ?

I want to calculate the capacitor charge given by equation (1)... But I am confused about the term "dv" . This is actually the differential of "v". Should I calculate it using the matlab function "diff" or "D"???

Like

dv=diff(v)

Is this right?

10 Rep
  • 2,217
  • 7
  • 19
  • 33
AK K Khan
  • 41
  • 7
  • 2
    Are you sure Equation 1 isn't `dq = c(v) * dv`? This would be the equation for a voltage-dependent capacitor. – Juderb Aug 27 '15 at 13:42
  • 1
    @Juderb is correct, which mean AK only really needs to know how _C_ varies with _V_, and how _V_ varies with _t_ is not relevant. Once _C(V)_ is known it should be integrated, not differentiated. – RPM Aug 27 '15 at 13:56
  • @RPM Thanks for pointing it out. I did a huge novice mistake in my deleted answer. – Ander Biguri Aug 27 '15 at 14:31
  • @Juderb,,Yes I did a mistake in writing the equation. Now I have corrected it. Its an equation of variable capacitor. – AK K Khan Aug 28 '15 at 01:18
  • @RPM,,,,. Now I have corrected it. Its an equation of variable capacitor. – AK K Khan Aug 28 '15 at 01:20

1 Answers1

1

MATLAB offers the surprisingly-named function integral to calculate the definite integral of a function c: RR between the limits 0 and V:

Q = integral(@c, 0, V);
rayryeng
  • 102,964
  • 22
  • 184
  • 193
  • Thanks for your answer.. I really appreciate it. I made a mistake in writing the equation previously, which I have corrected now. Its q= c(v)*dv ...... – AK K Khan Aug 28 '15 at 01:19