MATLAB: While using save command, I wanna choose directory which files can be saved into it.

save

for example;
p = rand(1, 10)
q = ones(10)
save('pqfile.txt', 'p', 'q', '-ASCII') % in here I cannot choose the directory which pqfile will save into it. I wanna save this file another directory, can I choose a different path?

Best Answer

You need to provide save with the path. eg.
save('C:\here.txt','p','p','-ASCII');
Or you can save to where you're working then use copyfile to put it where you want.
Or you can change directory to where you want the data, save it as you have just now, then change directory back to where you started (loop up "cd" in help)