Matlab Transfer function multiple single s terms
Show older comments
How can modify this script in order to get the transfer function shown in the picutre. Thanks.
C1 = 0.000000000150;
C2 = 0.000000000470;
R1 = 10000;
R2 = 180000;
R3 = 2700;
R4 = 56000;
A = 1/(C1*R2);
B = 1/(C2*R2);
C = (1/(C1*R1))*(1-G);
D = 1/(C1*C2*R1*R2);
G = (R3+R4)/R3;
%{
Numerator = {[G 0 0] };
Denominator = {[1 0] [A] [B] [C] [0 D]};
T = tf(Numerator, Denominator)
%}
T = tf([G 0 0], {[1] [A] [B] [C] [0 D]})
Accepted Answer
More Answers (1)
syms G C_1 R_2 C_2 R_1 s R_3 R_4
G = (R_3 + R_4)/R_3
vratio = G*s^2/ ( s^2 + s * (1/(C_1*R_2) + 1/(C_2*R_2) + 1/(C_1*R_1)*(1-G)) + 1/(C_1*C_2*R_1*R_2) )
vex = expand(vratio);
[N, D] = numden(vex)
Nc = collect(N, s);
Dc = collect(D, s);
vpretty = Nc/Dc
NCs = coeffs(Nc, s, 'all')
DCs = coeffs(Dc, s, 'all')
C1 = 0.000000000150;
C2 = 0.000000000470;
R1 = 10000;
R2 = 180000;
R3 = 2700;
R4 = 56000;
NC = double(subs(NCs, [C_1, C_2, R_1, R_2, R_3, R_4], [C1, C2, R1, R2, R3, R4]));
DC = double(subs(DCs, [C_1, C_2, R_1, R_2, R_3, R_4], [C1, C2, R1, R2, R3, R4]));
leading = DC(1);
NC = NC ./ leading;
DC = DC ./ leading;
sys = tf(NC, DC)
2 Comments
Walter Roberson
on 21 Feb 2023
Note that the reason to solve symbolically is to construct a general form that multiple sets of resister and capacitor values could be substituted into. After calculating NCs and DCs you could use matlabFunction() to create functions that would accept numeric inputs and calculate the coefficients.
But the CST can handle this directly without too much complication, even if the desire is to have a general expression
s = tf('s');
G = @(R_3,R_4) ((R_3 + R_4)/R_3);
vratio = @(C_1,C_2,R_1,R_2,R_3,R_4) G(R_3,R_4)*s^2/ ( s^2 + s * (1/(C_1*R_2) + 1/(C_2*R_2) + 1/(C_1*R_1)*(1-G(R_3,R_4))) + 1/(C_1*C_2*R_1*R_2) );
C1 = 0.000000000150;
C2 = 0.000000000470;
R1 = 10000;
R2 = 180000;
R3 = 2700;
R4 = 56000;
vratio(C1,C2,R1,R2,R3,R4)
Unrelated comment, but I have my suspicions about the expression for vratio in the question. I thought that circuits composed of just (positive) resistors and (positive) capacitors can't be unstable, whereas vratio clearly is.
Categories
Find more on Assumptions 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!



