how to export files to specific folders with GUI?

2 次查看(过去 30 天)
i have a GUI which calculates certain data and exports the data to an Excel file and '.jpeg' file of some plots. Now, what I want to do is to export the result to a specific folder like, "Problem 1" when the program is run for the first time ., "Problem 2" for second time and so on.. so i need a counter for the program and also export the results to specific problems.

回答(1 个)

Image Analyst
Image Analyst 2017-8-22
Use the fullfile function to build a complete filename (folder + base file name). Here's an example:
% Get the name of the file that the user wants to save.
% Note, if you're saving an image you can use imsave() instead of uiputfile().
startingFolder = userpath % Or "pwd" or wherever you want.
defaultFileName = fullfile(startingFolder, '*.*');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a file');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
fullFileName = fullfile(folder, baseFileName)
  2 个评论
Rohan Maharjajn
Rohan Maharjajn 2017-8-23
@Image Analyst what i want to do it to save the generated '.jpg' sand '.xlsx' files to a new folder.The folder must be created automatically when the user executes the code . eg: "Problem 1", where '1' is the value of the counter: so for nth execution, the folder name must be, "Problem n"

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by