It looks like you want to write a string to the text file, but SAVE is not a good fit for this. The help for SAVE -ASCII explains:
* MATLAB translates characters to their corresponding internal
ASCII codes. For example, 'abc' appears in an ASCII file as:
9.7000000e+001 9.8000000e+001 9.9000000e+001
I would suggest you use a different function for writing the file, such as FPRINTF:
prog = mfilename('fullpath');
[progpath,name,ext] = fileparts(prog);
pathtext = fullfile(progpath,'lastdir.txt')
fid = fopen(pathtext, 'w');
fprintf(fid, '%s', progpath);
fclose(fid);
Best Answer