I have code for push button where user will click on save, then a folder browser opens where user selects the folder to save the file.
Now here my code:
filename=('output.xls'); foldername = uigetdir; % ensure the folder name is valid
if ischar(foldername) % update the file name to include the folder name
filename = fullfile(foldername,filename); % open the file
fid = fopen(filename,'w'); if fid>0 % write the data to file
fprintf(fid, '%6s\t%6s\t\n', 'x', 'y'); fprintf(fid, '%6.4f\t%6.41f\t\n', result); fclose(fid); end end
So here by default the output file name will be output.xls
I want to have the user capability to set the name of the file. So how to do that?
Best Answer