2013-03-19 107 views
0

我試圖將當前工作空間中的一些數據保存到不同的文件夾中。我試過使用在Matlab中將數據保存到不同路徑中

save('c:\stp\vtp\train.txt','data','-ASCII'); 

其中數據是一個雙重矩陣。它給我錯誤信息

??? Error using ==> save 
Unable to write file c:\stp\vtp\train.txt: No such file 
or directory. 

我試過使用fullfile的語法,即使那麼它是相同的情況。我目前的工作文件夾是在不同的路徑。

+2

也許該目錄不存在? – 2013-03-19 21:32:42

回答

3

您可能需要首先運行mkdir。例如:

%Some data to save 
x = 1; 

%Try to save it in a deep, non-existent directory 
save(fullfile(tempdir,'sub1','sub2','sub3','sub4','data.mat'),'x'); 
% This will probably recreate your error 

%To fix, first create the directory 
mkdir(fullfile(tempdir,'sub1','sub2','sub3','sub4')) 
%Now save works 
save(fullfile(tempdir,'sub1','sub2','sub3','sub4','data.mat'),'x') %No error 
+0

感謝您的回覆。我明白了。我試圖拼錯我試圖保存的路徑。這導致了問題。 – ChanChow 2013-03-21 19:05:34

相關問題