how can i change the path when saving the file ?

when i am saving the file , only i can change the name of it but the path stay in file(.m)path. i want to save the file in a path different from the (.m)file how can i do this ? look at this code :
[filename,pathname] = uiputfile({'*.wav', '*.wav'}, 'Save current file as');
wavwrite(y,filename)
it saves the file in the same path of (.m)file , i want to save it in different path ?

 Accepted Answer

Replace
wavwrite(y,filename)
by
wavwrite( y, fullfile( pathname, filename) )

More Answers (1)

Here's my snippet that I always give people. It also handles if people click Cancel. Feel free to adapt it.
% 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)

Categories

Tags

Asked:

on 18 Dec 2015

Commented:

on 18 Dec 2015

Community Treasure Hunt

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

Start Hunting!