%Electronic-Devices-and-Circuit-Theory-Robert-Boylestad-Louis-Nashelsky-7th-Edition
%Ch.4.3 FIXED-BIAS CIRCUIT

clear

Rb=240; %240;
Rc=2.2; %2.2;
B=100;
Vcc=12;
Vcesat=0.2;

%Assuming Active Mode first
Vbe=0.7;
Ib=(Vcc-Vbe)/Rb
Ic=B*Ib
 
Vce=Vcc-Ic*Rc

if Ib<0 % if cut-off
    Vbe=Vcc;
    Ib=0;
    Ic=0;
    Vce=Vcc;
end

if Vce<Vcesat %if saturation
    Vbe=0.7;
    Vce=Vcesat;
    Ic=(Vcc-Vce)/Rc;
end


VCE=0:0.1:Vcc;
IC=(Vcc-VCE)/Rc;

plot(VCE,IC)
xlabel('Vce (V)')
ylabel('Ic (mA)')
title(['Ib, Ic Vce  ' num2str([Ib Ic Vce])])
hold on;
grid on;
plot(Vce,Ic,'o')
%hold off;

