Transfer function keeps coming up as empty

156 Views Asked by At

op Amp

clear all
close all
clc
format short eng

R1=100;
R2=100;
R3=500;
R4=100;
R5=50;

C1=1e-6;
C2=1e-6;
C3=2e-6;

syms s Vin Va Vb Vc Vd Ve Vf C1 C2 C3 R1 R2 R3 R4 R5 Vout

Zc1=1/(s*C1);
Zc2=1/(s*C2);
Zc3=1/(s*C3);

e(1)=Vin==Va; %KVL Op Amp
e(2)=Ve==Vf;
e(4)=((Va-Vb)/Zc1)-((Vb-Vd)/Zc2)-(Vb/R5)==0; % KCL Node B
e(5)=((Va-Vc)/R1)-((Vc-Vd)/R2)-((Vc-Ve)/Zc3)==0; %KCL Node C
e(6)=((Vb-Vd)/Zc2)-((Vc-Vd)/R2)==0; %KCL Node D
e(7)=((Vc-Ve)/Zc3)-((Ve-Vf)/R3)==0; %KCL Node E
e(8)=((Ve-Vf)/R3)-(Vf/R4)==0; %KCL Node F

sol=solve(e,Va,Vb,Vc,Vd,Ve,Vf,Vout); %Sol
Vout=sol.Vf/R5+R4;
Vout=eval(sol.Vout)
H=Vout/Vin % Gain is output over input
1

There are 1 best solutions below

0
On

You can't define resistors R1 R2 R3 R4 R5 as symbols when you already have their values, they got overwritten. Same for capacitors, C2 C3, and give some value for Vin in order to get value for Vout. Also, don't put the equations as a vector against variables, Vout is not a variable. just write the equations individually and leave the variables for MATLAB to determine automatically. Finally check the formula for Vout = Vf/R5 + R4, is it accurate?

clear, clc

R1 = 100;  R2 = 100;  R3 = 500; R4 = 100; R5 = 50;
C1 = 1e-6; C2 = 1e-6; C3 = 2e-6;

Vin = 5;  % Give it some value to get Vout
syms s Va Vb Vc Vd Ve Vf

Zc1=1/(s*C1);
Zc2=1/(s*C2);
Zc3=1/(s*C3);

e1 = Vin == Va; % KVL Op Amp
e2 = Ve == Vf;
e4 = (Va-Vb)/Zc1 - (Vb-Vd)/Zc2 - Vb/R5       == 0; % KCL Node B
e5 = (Va-Vc)/R1  - (Vc-Vd)/R2  - (Vc-Ve)/Zc3 == 0; % KCL Node C
e6 = (Vb-Vd)/Zc2 - (Vc-Vd)/R2 == 0; % KCL Node D
e7 = (Vc-Ve)/Zc3 - (Ve-Vf)/R3 == 0; % KCL Node E
e8 = (Ve-Vf)/R3  - Vf/R4      == 0; % KCL Node F

sol = solve(e1,e2,e4,e5,e6,e7,e8); %Sol
Vout = sol.Vf/R5 + R4;
H = Vout/Vin % Gain is output over input

Output:

H =
 20
 20
 20