Collect the coefficients of a symbolic expression for an Op Amp circuit function

Hello,
I have writen function for Op Amp Sallen-Key Circuit. All values including the 's' are used as symbolic expresion.
I would need to rearange the variables in order to have on the left side the V2/V1. I have been trying to use solve(V2,V1) but are not rearanged.
On the right side I would need the denominator to be on the form of . I have been trying with factor(G) but it gives denominator on the form of .
Is there any way to achieve the above.
Giannis

 Accepted Answer

syms A Ga Gb G1 G2 C2 V1 V2 s
%Defining expression
expr = V2 == A*((G1*G2*V1 + C2*G2*V2*s)/(C2^2*s^2+G1*G2 + C2*G1*s + 2*C2*G2*s) - Gb*V2/(Ga+Gb))
expr = 
%Isolating V2 to LHS
expr = isolate(expr,V2)
expr = 
%Assuming that V2/V1 can isolated from the expression
%Dividing both sides of the expression by V1 to obtain V2/V1 on the left side
expr = expr/V1
expr = 
If you want to simplify the RHS, this approach works good enough -
%Get numerator and denominator of RHS in a rational form
[n,d] = numden(rhs(expr))
n = 
d = 
%Redefine the expression
expr = lhs(expr) == n/d
expr = 
If you want the coefficient of s^2 in the denominator to be 1, get its coefficient by using coeffs and divide d by the coefficient.

4 Comments

Thank you Dyuman Joshi for your reply
Still I am not able to bring the denominatior to the form . I can get the funciton V2/V1 as per your guidance but I can not brink a funciton to the form I need when I devide with the coeficient of the s^2.
dcoef=coeffs(d,s)
%Devide numerator and denominator with the s^2 coeficient
n=n/(C2^2*Ga + C2^2*Gb + A*C2^2*Gb)
d=d/(C2^2*Ga + C2^2*Gb + A*C2^2*Gb)
I have been trying to use partfrac(d) and simplify(d) but seems are not giving whant I need.
Giannis
Use the collect function first, then coeffs
syms A Ga Gb G1 G2 C2 V1 V2 s
%Defining expression
expr = V2 == A*((G1*G2*V1 + C2*G2*V2*s)/(C2^2*s^2+G1*G2 + C2*G1*s + 2*C2*G2*s) - Gb*V2/(Ga+Gb))
expr = 
%Isolating V2 to LHS
expr = isolate(expr,V2)
expr = 
%Assuming that V2/V1 can isolated from the expression
%Dividing both sides of the expression by V1 to obtain V2/V1 on the left side
expr = expr/V1
expr = 
%Get numerator and denominator of RHS in a rational form
[n,d] = numden(rhs(expr))
n = 
d = 
n = collect(n, s)
n = 
d = collect(d, s)
d = 
[dc,dterms] = coeffs(d, s);
Denominator_Coefficients = dc.'
Denominator_Coefficients = 
Denominator_s_terms = dterms.'
Denominator_s_terms = 
%Redefine the expression
expr = lhs(expr) == n/d
expr = 
.

Sign in to comment.

More Answers (0)

Categories

Find more on Numerical Integration and Differential Equations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!