Saving results to the specific location
1 view (last 30 days)
Show older comments
Pankaj Dubey
on 14 Jun 2018
Commented: Walter Roberson
on 15 Jun 2018
Hi, I am a novice coder, just started. I am doing an analysis on a image and eventually extract a excel files with values. I start the code with uigetfile and end with save as with uiputfile. How can I change the end of the code so that my 'save as' location is same as the from where I picked up the Image file. Basically I would like to make the default 'save as' location to the same folder where my images are. uiputfile is not neccessay here if I can directly save in the folder. I hope I made sense. thank you
my codes-
if true
%
defaultFileName = fullfile('*.tif*');
[baseFileName, folder] = uigetfile(fullfile('*.tif*'),'select a file');
fullFileName = fullfile(folder, baseFileName)
Image = imread(fullFileName);
% some formula_results
[FileName, folder] = uiputfile({'*.xls'},'Save As...',[xlfilename '.xls']);
xlswrite([folder FileName ],formula_results);
end
0 Comments
Accepted Answer
Walter Roberson
on 15 Jun 2018
[FileName, folder] = uiputfile({'*.xls'},'Save As...', [xlfilename '.xls'], folder);
to give the folder as the default location.
But what you are probably looking for is
[~, basename, ~] = fileparts(fullFileName);
newFullName = fullfile(folder, [basename '.xls']);
xlswrite( newFullName, formula_results );
2 Comments
Walter Roberson
on 15 Jun 2018
Should probably have been
[FileName, folder] = uiputfile({'*.xls'},'Save As...', folder);
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!