MATLAB: How to read specified letters from ascii file

MATLABopen file

i want prgrm that reads ascii file but only the letters 'a' to 'z' using ascii code 97:122 and i want to put those letters in new file and save them

Best Answer

inputFileName = 'C:\input.txt';
outputFileName = 'C:\output.txt';
fileID = fopen(inputFileName,'r');
A = fread(fileID,'*char');
fclose(fileID);
A = A(A >= 97 & A <= 122); % using logical indexing to keep only 'a' to 'z'
fileID = fopen(outputFileName,'w');
fprintf(fileID,'%s',A);
fclose(fileID);