Saving results to the specific location
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2018-6-15
[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 个评论
Walter Roberson
2018-6-15
Should probably have been
[FileName, folder] = uiputfile({'*.xls'},'Save As...', folder);
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!