AK K Khan
AK K Khan

Reputation: 41

Using diff (v) or D(v) in matlab

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?

Upvotes: 0

Views: 128

Answers (1)

user2271770
user2271770

Reputation:

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);

Upvotes: 1

Related Questions