我只是給了一部分讓我頭痛的MATLAB代碼。未定義的函數或變量「kernel_type」
function [hm,sm] = SKSClab(filename,data_type,maxk,true_labels,plot_flag)
%Inputs:
% filename: .txt file (or .jpg for images) with the data (instances as rows, features as columns)
% data_type:
% 1) net_unw = unweighted network (filename represents the adjacency list)
% 2) net_w = weighted network (filename represents the adjacency list)
% 3) vector = generic data points
% 4) ts = time-series
% 5) img = image
% maxk: maximum number of clusters to look for
% true_labels: labels if present
% plot_flag: 1 -> plot results, 0-> do not plot anything
然後
switch data_type
case 'vector'
THR_dim = 100;
if(size(X,2)<THR_dim)
kernel_type = 'RBF_kernel';
else
kernel_type = 'cosine_kernel'; %use cosine kernel when enough features are present
end
case 'ts'
kernel_type = 'corrrbf_kernel';
case 'net_w'
kernel_type = 'cosine_kernel';
case 'net_unw'
kernel_type = 'cosine_kernel';
case 'img'
kernel_type = 'chisquared_kernel';
end
%Tuning
tunestruct = {samplefunc,numreps,data_type,MS_criterion};
[Xtrain,optk,optsig2,tuningExtras] = tuneSKSC(data,kernel_type,maxk,tunestruct);
當我調用這樣
SKSClab('proba',3,6,1)
代碼我
Loading data...
Undefined function or variable "kernel_type".
Error in SKSClab (line 179)
[Xtrain,optk,optsig2,tuningExtras] = tuneSKSC(data,kernel_type,maxk,tunestruct);
也有這樣的
定義的其他功能function [Xtrain,optk,optsig2,extras] = tuneSKSC(datastruct,kernel,maxk,tunestruct)
什麼問題?我應該定義kernel_type
嗎?我沒有太多的MATLAB實驗。
不,proba.txt是文件名,3是向量的參數。 – MPejic
@MPejic好的,我會更正答案。但問題仍然是你沒有給功能預期的參數。該函數真的期望在第二個參數中的那些字符串之一,你給它一個數字/ –
@參數應該如何? – MPejic