%% modbent.m is my version of the IRI95 function
%% XE1 which uses the harmonized Bent Model to 
%% model the topside ionosphere.
%%

function eden=modbent(altmat,hmf2,nmf2,beta,eta,delta,zeta)

% altmat = altitude of point of interest (km)
% hmf2 = F2 height (km)
% nmf2 = F2 electron density (e-/m^3)
% beta, eta, delta, zeta = Bent model parameters
% 
% eden = electron density of point of interest

altmat=altmat(:);
hmf2=hmf2(:);
nmf2=nmf2(:);
beta=beta(:);
eta=eta(:);
delta=delta(:);
zeta=zeta(:);

dxdh=(1000-hmf2)./700;
x0=300-delta;
xmx0=(altmat-hmf2)./dxdh;
x=xmx0+x0;
eptr1=eptr(x,beta,394.5)-eptr(x0,beta,394.5);
eptr2=eptr(x,100,300)-eptr(x0,100,300); 
y=beta.*eta.*eptr1+zeta.*(100*eptr2-xmx0);
y=y.*dxdh;
eden=nmf2.*exp(-y);                             

      