function x=expf1(t,terms) x=0.5; count=1; while count <= terms coeff = (1-exp(-j*count*)); harmonic = coeff*exp(-j*count*pi*t); % negate count to get the negative harmonic count = -count; coeffneg = 2*sinc(count*pi/2) * exp(-j*count*pi/2); harmonicneg = coeff*exp(-j*count*pi*t); % negate count again to continue in the loop count = -count; x=x + harmonic + harmonicneg; count = count+1; end