MATLAB: How can i change the path when saving the file

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 ?

Best Answer

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