In: Electrical Engineering
e-01 = 0.1
Code :
Taking inputs :
Output _plot :
Raw_code :
kn = input('Enter kn value(un*cox*(w/l):'); %taking values from
user
vgs = input('Enter the Vgs value :');
vt = input('Enter Vt value :');
vds = 0:0.4:10; %sweeping vds from 0 to 10v
for i=1:length(vds)
if(vgs<vt) %mosfet is off
current(i)=0;
elseif(vds(i) >= (vgs-vt))
current(i)=0.5*kn*(vgs-vt)^2; %saturation current equation
elseif ( vds(i) < (vgs-vt))
current(i) = kn * ((vgs-vt)*vds(i) - 0.5*(vds(i)^2)); %triode
current equation
end
end
plot(vds,current,'b')
title('I-V characteristics ')
xlabel('Vds v')
ylabel('Current A')