xvec=0.1:0.1:5.0 jmax=20 jvec=0:1:jmax [xmat,jmat]=meshgrid(xvec,jvec) summandvec=(2.*jmat+1).*exp(-jmat.*(jmat+1).*xmat) Z=sum(summandvec) plot(xvec,Z)