The related files can be downloaded at kr.mathworks.com/matlabcentral/fileexchange/175693-nonlinear-equation-solver-with-matlab. %nm04p11.m clear betaF=100; betaR=1; alphaR=betaR/(betaR+1); Is=1e-15; Isc=Is/alphaR; % BJT parameters VT=(273+27)/11605; % Thermal voltage: VT=(273+T)/11605 VCC=15; VBB1=5; RB1=33.3e3; RC1=5e3; RE1=3e3; RE2=2e3; RC2=2.7e3; % To find the equivalent of the voltage divider biasing circuit %VBB1=VCC*R2/(R1+R2); RB1=parallel_comb([R1 R2]); % Exponential model based approach iC=@(v)Is*exp(v(1)/VT)-Isc*exp(v(2)/VT); % Eq.(E4.4.4a) iB=@(v)Is/betaF*exp(v(1)/VT)+Isc/(betaR+1)*exp(v(2)/VT); % Eq.(E4.4.4b) % Eq.(P4.10.1) with v=[vBE1 vBC1 vEB2 vCB2] eq=@(v)[VCC-VBB1+v(2)-RC1*(iC(v(1:2))-iB(v(3:4)))+RB1*iB(v(1:2)); VBB1-RB1*iB(v(1:2))-v(1)-RE1*(iC(v(1:2))+iB(v(1:2))); VCC+v(4)-RC1*(iC(v(1:2))-iB(v(3:4)))-RC2*iC(v(3:4)); VCC-v(3)+v(4)-RE2*(iC(v(3:4))+iB(v(3:4)))-RC2*iC(v(3:4))]; options=optimoptions('fsolve','Display','off'); %,'TolX',1e-10,'TolFun',1e-10); %,'Diagnostics','off'); v0 = [0.7; 0.4; 0.7; 0.4]; % Initial guess for v=[vBE1 vBC1 vEB2 vCB2] v = fsolve(eq,v0,options); % v = Newtons(eq,v0); % Alternatively, VBE1=v(1); VBC1=v(2); VEB2=v(3); VCB2=v(4); format short e IB1=iB(v(1:2)), IC1=iC(v(1:2)) IB2=iB(v(3:4)), IC2=iC(v(3:4)) VC1=VCC-RC1*(IC1-IB2), VB1=VC1+VBC1, VE1=VB1-VBE1 VE2=VCC-RE2*(IC2+IB2), VB2=VE2-VEB2, VC2=VB2+VCB2 format short function [x,fx,xx]=Newtons(f,x0,TolX,MaxIter,varargin) % Newtons.m to solve a set of nonlinear eqs f1(x)=0, f2(x)=0,.. by the Newton method. % Input: f = a 1st-order vector ftn equivalent to a set of equations % x0 = Initial guess of the solution % TolX = Upper limit of |x(k)-x(k-1)| % MaxIter = Maximum # of iteration %output: x = Point which the algorithm has reached % fx = f(x(last)): Residual error % xx = History of x % Copyleft: Won Y. Yang, wyyang53@hanmail.net, CAU for academic use only h=1e-4; % 1e-5; TolFun=eps; EPS=1e-6; fx=feval(f,x0,varargin{:}); Nf=length(fx); Nx=length(x0); if Nf~=Nx, error('Incompatible dimensions of f and x0!'); end if nargin