%"Tabulate" class: Write a program to calculate e from the definition clear all % % Switch between output options for screen or file %iOut=1; iOut=fopen('NumericalOutput.txt','w'); fprintf(iOut,' x (1+x)^(1/x) Diff(pct)\n'); % eValue=exp(1); % xVals=[0.5,0.1,0.01,0.001,0.0001,0.00001,0.000001]; NN=length(xVals); for iN=1:NN x=xVals(iN); eLimit=(1+x)^(1/x); eDiff=100*(eValue-eLimit)/eValue; fprintf(iOut,'%8.6f %10.8f %5.3g\n',[x,eLimit,eDiff]); end % % Only "close" a file if it is specifically "opened" fclose(iOut);