MATLAB: Need help with correcting the code below

errorfor loopplot

Hello,
I am trying to plot this curve but failing to do so. I want to plot Vth as a function of shiM (3.5:0.25:5.5)
But maybe I am not using my for loop correctly. Could anyone please have a look? I really need help. Here is the code:
clc;
mo= 9.11e-31;
mn= 1.1*mo
mh=0.5*mo
k=1.3e-23;
T=300;
Eg=1.166*1.6e-19 %%Eg=1.166ev
h=6.63e-34
q= 1.6e-19;
alpha= 0.000473*q
B=636;
Na= 1e21; %%unit in meter cube,,, we have to change it for (b)
X=4.1*q %%%electron affinity value in eV CHECK
tox= 0.6e-9; %%in meter .. i took tox=0.6nm
eps0 = 8.85e-12;
Kox = 3.95; %%%oxide dielectric constant
Ks = 11.7;%%%semiconductor dielectric constant
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Nv= 2*((2*3.142*mh*k*T)/h^2)^1.5
Nc= 2*((2*3.142*mn*k*T)/h^2)^1.5
ni=sqrt(Nc*Nv)*exp((-Eg)/(2*k*T))
Egt= Eg- ((alpha*(T^2))/(B+T))
shiF= k*T* log(Na/ni) %%%joules
shiS= abs(X+ (Eg/2)+ shiF) %%joule

Cox= (Kox * eps0)/tox
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
i=1;
for shiM=3.5*q:0.25*q:5.5*q %%%assumed
shiMS(i)= abs(shiM - shiS) %%joule
%%now calculatetion of Vth
Vth= abs(shiM - shiS)+ (2*shiF) + sqrt(4*q*Ks*eps0*Na*shiF)/Cox %%unit in volts
i=i+1;
end
shiM=3.5*q:0.25*q:5.5*q
plot(shiM, Vth, '-*r')
title('Threshold voltage vs given parameter curve'), xlabel('phiM'), ylabel('Threshold voltage')

Best Answer

Change
Vth= abs(shiM - shiS)+ (2*shiF) + sqrt(4*q*Ks*eps0*Na*shiF)/Cox %%unit in volts

to
Vth(i) = abs(shiM - shiS)+ (2*shiF) + sqrt(4*q*Ks*eps0*Na*shiF)/Cox %%unit in volts