2014-10-06 75 views
1

我想在負載功能使用num2str如下未定義功能「num2str」類型的輸入參數「雙重」

route=3; 
samples=1; 
pct=100; 

path('C:\') 
load(['B2A_Sample_r',num2str(route),'_',num2str(pct),'%_',num2str(1000+samples)]) 

我也試過:

filename=char(['B2A_Sample_r',num2str(route),'_',num2str(pct),'%_',num2str(1000+samples)]); 
load(filename,'-mat') 

我每次遇到這個錯誤都必須關閉並重新啓動matlab。

回答

5

您每次運行時都清除path,所以MATLAB無法找到任何文件或功能,無論是否內置(包括num2str)。每次嘗試時,它只會在C:\之後出現,然後放棄。試試這個:

route=3; 
samples=1; 
pct=100; 
filename=char(['B2A_Sample_r',num2str(route),'_',num2str(pct),'%_',num2str(1000+samples)]); 
directory = 'C:\'; 

fullfilename = fullfile(directory,filename); 

load(fullfilename); 
+0

+1斑點!另一種解決方案是'addpath('C:\')' – 2014-10-06 23:04:03

相關問題