plot input current versus input voltage as function of six fixed values of output voltage for a common emitter bjt according to the ebers-moll equations in matlab

main.m
% Constants
VT = 26e-3;
IS = 1e-16;
BF = 100;
BR = 1;

% Input Voltage
Vi = 0:0.01:1;

% Output Voltage
Vo = [2, 4, 6, 8, 10, 12];

% Calculation
IC = zeros(length(Vo), length(Vi));
for i = 1:length(Vo)
    for j = 1:length(Vi)
        VBE = VT*log(IC(i, j)/IS + 1);
        VCE = Vo(i) - IC(i, j)*BR;
        IC(i, j) = IS*(exp(VBE/VT) - 1);
    end
end

% Plot
figure;
hold on;
colors = ['b', 'r', 'g', 'c', 'm', 'y'];
for i = 1:length(Vo)
    plot(Vi, IC(i, :), colors(i));
end
xlabel('Input Voltage (V)');
ylabel('Input Current (A)');
legend('Vo = 2V', 'Vo = 4V', 'Vo = 6V', 'Vo = 8V', 'Vo = 10V', 'Vo = 12V');
title('Input Current vs Input Voltage for Different Output Voltages');
hold off;
696 chars
35 lines

related categories

gistlibby LogSnag