MATLAB: Problems with uiputfile

guiuiputfile

I have a GUI that opens .txt or .xls file and then processes the file. I would like to allow the user the ability to save the results to a .txt and/or .xls file and to select the destination folder. I use 'uigetfile' to open my files. It works great! I am able to open and read both file formats. I am trying to use 'uiputfile' to save the results. This is where I am having trouble. The window opens, I type in the new file name and click save… but the file doesn't save. I can understand this part… I assume it should work similarly to uigetfile. I tried using 'xlswrite' after 'uiputfile.' The file saves but to the wrong(current) directory. I am unsure how to mesh the two commands. Any ideas?
Should I add a new directory? If so, how do I select which directory the file will be saved to?
Can I add the new path name to the xlswrite code to select the destination of the file?
Any help is greatly appreciated… Thanks!

Best Answer

[filename, pathname] = uiputfile(...);
fullname = fullfile(pathname,filename);
xlswrite(fullname, YourData);