how to declarate variables to solve this problem
이전 댓글 표시
if i have two function first
function [label,s] = LSC(data,k,opts)
% Set and parse parameters
if (~exist('opts','var'))
opts = [];
end
***%[how to define variables p and r to take values from loop]***
maxIter = 100;
numRep = 10;
mode = 'kmeans';
nSmp=size(data,1);
% Landmark selection
if strcmp(mode,'kmeans')
kmMaxIter = 5;
if isfield(opts,'kmMaxIter')
kmMaxIter = opts.kmMaxIter;
end
kmNumRep = 1;
if isfield(opts,'kmNumRep')
kmNumRep = opts.kmNumRep;
end
[dump,marks]=litekmeans(data,p,'MaxIter',kmMaxIter,'Replicates',kmNumRep);
[label,s] = kmedo(U',k);
end
second function
function Accuracy=yarbb(data,x)
%for i=1:100
rng('default')
n = size(data,1);
data_rand = data(randperm(n),:);
m = ceil(n/10);
k = 1:m:n-m;
test = data_rand(k:k+m-1,:);
train = [data_rand(1:k-1,:); data_rand(k+m:end,:)];
adj=ed(train,data);
for i=1:100
rng('default')
***for p=3:5
for r=2:5
[p,r]
[cluster_labels,s] = LSC(adj,x);***
auc= (ndash + 0.5 * nddash)/(ndash+nddash+nn);
end
Accuracy = mean(auc)
end
end
in second function i used for loop to pass variables "p" and "r" to first function to calculate "s" and return again to second function , but when i used for loop for variables "p" and "r" this caused errors that are [undefined variables "p" and adj(0,0) not found).
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Big Data Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!