Reputation: 25
I run the following code and expect to get a vector IB, I do get a vector but all of whose elements are same I don't know what the problem is with this code?
function IB = ibtest(VCC)
RL = [1000, 10000, 200000, 400000, 600000, 800000, 1000000];
RB = 22000;
RP = 50;
R = 470;
B = 300;
i = 0;
for t = 1:length(RL)
i = i+1;
IB(i) = ((VCC - 2.1)*(RL(i) + RP)) / ( (RL(i) * RP) + (RB*(RL(i) + RP)) + (301 * 470 * (RL(i) + RP)) );
end
IB
end
Upvotes: 1
Views: 112
Reputation: 801
There's nothing wrong with your code. You should get equal numbers as you increase numerator and denominator by the same fraction every iteration. Try running this code:
function IB = ibtest(VCC)
RL = [1000, 10000, 200000, 400000, 600000, 800000, 1000000];
RB = 22000;
RP = 50;
R = 470;
B = 300;
for t = 1:length(RL)
num = ((VCC - 2.1)*(RL(t) + RP))
denom = ( (RL(t) * RP) + (RB*(RL(t) + RP)) + (301 * 470 * (RL(t) + RP)) )
IB(t) = num / denom
end
end
I also don't know what you want to compute so if you don't get what you expect there must be something wrong with the formula.
Upvotes: 1