2014-06-23 39 views
0

我在線運行matlab代碼時出現錯誤。錯誤是:用於'int32'類型輸入參數的未定義函數'relabel'。 import_experiment_label(第22行)中的錯誤runs = relabel(run);

警告:名稱不存在或不是一個目錄:...... \ toolbox_misc

未定義功能「重新標記」類型「的Int32」的輸入參數。 Import_experiment_label(第22行)中的錯誤 runs = relabel(run);

我試着下載matlab toolbox misc在線,但還是無法修復 這個問題。任何人都可以幫助我?非常感謝!

以下是原代碼:

% Load the text experiment-label file to cell 
% Kinalizer: /share/Bot/Research/mvpa_data/Haxby_6_subjects 
% mac: /Users/kittipat/Downloads/Research/Haxby_7_subjects 
% subjID = 2; 
inDir = ['/Users/kittipat/Downloads/Research/Haxby_7_subjects/subj',num2str(subjID),'/']; 
inFile = 'labels.txt'; 
outDir = ['/Users/kittipat/Downloads/Research/Haxby_7_subjects/subj',num2str(subjID),'/matlab_format']; 

fileID = fopen(fullfile(inDir,inFile)); 
% !!!!! Must remove "labels chunks" at the top of the txt file first 
myCell = textscan(fileID, '%s %d'); 
fclose(fileID); 
category_name = myCell{1}; 
run = myCell{2}; 

% Make sure the run numbers are well-ordered from 1 to R 
addpath('../../../toolbox_misc/'); 
runs = relabel(run); 
num_run = length(unique(runs)); 
num_time_stamp = length(runs); 

% Make associate labels (needs input from user) 
category_name_list = {'rest','face','house','cat','bottle','scissors','shoe','chair','scrambledpix'}; 
assoc_label_list = [0,1,2,3,4,5,6,7,8]; 
num_category = length(assoc_label_list); % including 'rest' 

assoc_label = zeros(num_time_stamp,1); 
regs = zeros(num_category,num_time_stamp); 
for i = 1:num_time_stamp 
    assoc_label(i) = assoc_label_list(strcmp(category_name{i},category_name_list)); 
    regs(assoc_label(i)+1,i) = 1; % 'rest' is column 1 
end 

regs_with_rest = regs; 
regs = regs(2:end,:); % exclude "rest" in the 1-st column 
num_category = num_category - 1; % exclude the "rest" 

save(fullfile(outDir,'experiment_design'),... 
    'category_name',...% the category name for each time stamp 
    'assoc_label',...% the number label for each time stamp 
    'assoc_label_list',...% the mapping between category_name and assoc_label 
    'category_name_list',...% list of the category name 
    'num_category',...% number of categories excluding "rest" 
    'regs',...% the category matrix excluding "rest" 
    'num_run',...% number of runs in well-ordered integer 
    'runs'... % the run# for each time stamp 
    ); 

%% plot the figure 
h1 = figure; 
subplot(4,1,2); plot(assoc_label,'b.-'); 
xlim([1, num_time_stamp]); 
set(gca,'YTick',0:max(assoc_label(:))); set(gca,'YTickLabel',category_name_list); 
subplot(4,1,1); plot(runs,'r.-'); 
title('run number after relabeling --> runs'); xlim([1, num_time_stamp]); 
subplot(4,1,3); imagesc(regs_with_rest); 
title('original design matrix --> regs\_with\_rest'); 
set(gca,'YTick',1:(num_category+1)); set(gca,'YTickLabel',category_name_list); 
subplot(4,1,4); imagesc(regs); 
title('after "rest" is removed --> regs'); 
xlabel('time stamps'); 
set(gca,'YTick',1:num_category); set(gca,'YTickLabel',category_name_list(2:end)); 
print(h1,'-djpeg',fullfile(outDir,'experiment_design.jpg')); 
+0

你是什麼意思*在線運行matlab代碼*?你是否在'import_experiment_label'中編寫了調用'relabel'函數的代碼,或者使用其他軟件? – Geoff

+0

我無法找到名爲「relabel」的工具箱功能。因此,你有沒有見過它,它正常的matlab拋出一個異常 –

+0

我使用一些其他在線軟件。 – user3761566

回答

0

我解決這個問題重新標記。然後我按如下方式更改部分代碼。

inDir = ['/D disk/MATLAB/R2014a/subjX/beta_extraction_for_Haxby_matlab_toolbox_v1_8/subj',num2str(subjID),'/']; 

inFile = 'labels.txt'; 

outDir = ['/D disk/MATLAB/R2014a/subjX/beta_extraction_for_Haxby_matlab_toolbox_v1_8/subj',num2str(subjID),'/matlab_format']; 

另一個錯誤出現:

import_experiment_label 未定義函數或變量 'subjID'。

錯誤import_experiment_label(第7行) 下載= [ '/ d磁盤/ MATLAB/R2014a/subjX/beta_extraction_for_Haxby_matlab_toolbox_v1_8​​/SUBJ',num2str(subjID), '/'];

如何解決這個問題?我不知道這裏有什麼問題。感謝你們!

+0

以及其他錯誤來了: – user3761566

+0

使用集合錯誤 找到了錯誤的屬性值。 對象名稱:座標軸 屬性名稱:'XLim' 值必須增加且不爲NaN。 xlim錯誤(第43行) set(ax,'xlim',val); import_experiment_label(第57行)中的錯誤xlim([1,num_time_stamp]); – user3761566

+0

如何解決繪圖問題?感謝你們! – user3761566

相關問題