xvec=0.1:0.1:5.0 nvec=0:1:4 expvec=exp(-xvec) [expmat,nmat]=meshgrid(expvec,nvec) summandvec=expmat.^nmat Z=sum(summandvec) plot(Z,xvec)