Reputation: 2299
Is there a way to save a matrix in Matlab in a folder different from the working directory? Suppose the current working directory is /Users/username/Desktop/Paper1 and the code is
clear all
load A
R=zeros(100,1)
for s=1:100
R(s)=randn(1)+A(s);
end
%save R in /Users/username/Desktop/Paper2
Upvotes: 0
Views: 1059
Reputation: 160
You can put the full path in the filename argument for save
.
save('/path/to/desired/folder/filename.mat', R)
Upvotes: 3
Reputation: 1935
Yes. This is a way. Type in the command window
cd /Users/username/Desktop/Paper2
than
save('file.mat','R')
If you want to go back to your previous current directory you can add to your code.
currentFolder = pwd
cd /Users/username/Desktop/Paper2
save('file.mat','R')
cd(currentFolder)
Upvotes: 0