Symbolsk løsning av nodeligninger med Matlab: Difference between revisions
From ift
mNo edit summary |
mNo edit summary |
||
| Line 2: | Line 2: | ||
<pre> | <pre> | ||
% Using Kirchoff's current law (KCL) on a source follower configuration | % Using Kirchoff's current law (KCL) on a source follower configuration | ||
% to find | % to find Vo as a function of Vin | ||
% Only Cgd is considered (Zc) | % Only Cgd is considered (Zc) | ||
% Kjetil Ullaland | % Kjetil Ullaland | ||
syms s Vin Vo Vgs Zc gm Rl Rs R | |||
eq1='(Vo-Vgs)/(R+Zc)+gm*Vgs+Vo/Rl=0'; | |||
eq2='(Vgs-Vo)/(R+Zc)+(Vgs-Vin)/Rs=0'; | |||
eq1=subs(eq1,Zc,'1/(s*C)'); | |||
eq2=subs(eq2,Zc,'1/(s*C)'); | |||
disp('KCL for circuit node 1:'); | |||
pretty(eq1); | |||
disp('KCL for circuit doc prettynode 2:'); | |||
pretty(eq2); | |||
disp('Solve for Vgs'); | disp('Solve for Vgs'); | ||
vgs_solved=solve( | vgs_solved=solve(eq2,Vgs); | ||
pretty(simplify(vgs_solved)); | pretty(simplify(vgs_solved)); | ||
disp('Solve for | disp('Solve for Vo(vin)'); | ||
eq3=subs(eq1,Vgs,vgs_solved); | |||
Vo_solved=solve(eq3,Vo); | |||
pretty(simplify( | pretty(simplify(Vo_solved/Vin)) | ||
</pre> | </pre> | ||
Revision as of 08:46, 13 September 2016
Using Kirchoff's current law (KCL) on a source follower configuration to find Vout as a function of Vin
% Using Kirchoff's current law (KCL) on a source follower configuration
% to find Vo as a function of Vin
% Only Cgd is considered (Zc)
% Kjetil Ullaland
syms s Vin Vo Vgs Zc gm Rl Rs R
eq1='(Vo-Vgs)/(R+Zc)+gm*Vgs+Vo/Rl=0';
eq2='(Vgs-Vo)/(R+Zc)+(Vgs-Vin)/Rs=0';
eq1=subs(eq1,Zc,'1/(s*C)');
eq2=subs(eq2,Zc,'1/(s*C)');
disp('KCL for circuit node 1:');
pretty(eq1);
disp('KCL for circuit doc prettynode 2:');
pretty(eq2);
disp('Solve for Vgs');
vgs_solved=solve(eq2,Vgs);
pretty(simplify(vgs_solved));
disp('Solve for Vo(vin)');
eq3=subs(eq1,Vgs,vgs_solved);
Vo_solved=solve(eq3,Vo);
pretty(simplify(Vo_solved/Vin))
Using Kirchoff's current law (KCL) on single transistor stage, fig. 9.18 to find Vo as a function of Is
% Using Kirchoff's current law (KCL) on single transistor stage, fig. 9.18
% to find Vo as a function of Is
% Kjetil Ullaland, 2015
syms Vo V1 s gm R1 R2 C C1 C2 Is Zc Rz;
%% With feedforward capacitor
eq1=sym('(Vo-V1)/Zc+gm*V1+Vo/R2+Vo*s*C2=0');
eq2=sym('(V1-Vo)/Zc+V1*s*C1+V1/R1+Is=0');
eq1=subs(eq1,Zc,'1/(s*C)');
eq2=subs(eq2,Zc,'1/(s*C)');
solV1=solve(eq2,V1);
eq3=subs(eq1,V1,solV1);
SolVo=simplify(solve(eq3,[Vo]));
disp('With capacitor only in feedforward loop');
pretty(simplify(SolVo/Is));
%% With series resistor and capacitor in feedforward loop
eq1=sym('(Vo-V1)/(Zc+Rz)+gm*V1+Vo/R2+Vo*s*C2=0');
eq2=sym('(V1-Vo)/(Zc+Rz)+V1*s*C1+V1/R1+Is=0');
eq1=subs(eq1,Zc,'1/(s*C)');
eq2=subs(eq2,Zc,'1/(s*C)');
solV1=solve(eq2,V1);
eq3=simplify(subs(eq1,V1,solV1));
SolVo=solve(eq3,[Vo]);
disp('With series resistor and capacitor in feedforward loop');
pretty(simplify(SolVo/Is));
