function [Id]=EKV(W,L,uCox,UT,Vt,n,Vg,Vs,Vd,lambda,sty)
%function [Id]=EKV(W,L,uCox,UT,Vt,n,Vg,Vs,Vd,lambda,sty)
%Plots the EKV model behaviour. Either Vg, Vs, Vd can be vectors.

%W=1;
%L=1;
%uCox=270e-6; % A/V^2 180nm NMOS
%UT=26e-3; %V
beta=uCox*W/L;
%Vt=450e-3; %V 180nm book P 45
%Vg=0:0.01:3.3;
%n=1.5;
%Cox=3.9*8.854e-12*5e-9 %book page 41
%Id0=(n-1)*uCox*UT^2
Is=2*n*beta*UT^2;

%with channel modulation effects Is=Is*L/(L-c*sqrt(Vd-Vp)) where Vp is the
%pinch-off voltage and c is a parameter dependent on acceptor doping N_A.
%More crudely with lambda parameter below

%lambda=0.03;

%1+lambda*((Vd-Vs)-(Vg-Vt-n*Vs))

Id=( Is*log(1+exp((Vg-Vt-n*Vs)/(2*n*UT))).^2  - Is*log(1+exp((Vg-Vt-n*Vd)/(2*n*UT))).^2 ) .* (1+lambda*((Vd-Vs) ));%-(Vg-Vt-n*Vs)));

if (max(size(Vg))>1)
 plot(Vg,Id,sty);
 ylabel('I_D','fontname','times','fontsize',14);
 xlabel('V_{GS}','fontname','times','fontsize',14);
end;
if (max(size(Vs))>1)
 plot(Vs,Id,sty);
 ylabel('I_D','fontname','times','fontsize',14);
 xlabel('V_{S}','fontname','times','fontsize',14);
end;
if (max(size(Vd))>1)
 plot(Vd,Id,sty);
 ylabel('I_D','fontname','times','fontsize',14);
 xlabel('V_{DS}','fontname','times','fontsize',14);
end;
%legend('basic strong inversion','basic weak inversion','EKV','Location','SouthEast');
%set(gca,'yscale','log','fontname','times','fontsize',14);
set(gca,'fontname','times','fontsize',14);

%print -deps2c '../fig/BSIMvsEKV.eps'
%system('convert ../fig/BSIMvsEKV.eps ../fig/BSIMvsEKV.pdf');
end