how to use for loop to solve this problem
Show older comments
if i have two function
the first function use variables "p" and "r" and result s as follow
function [label,s] = LSC(data,k)
if (~exist('opts','var'))
opts = [];
end
N=5;
p =20;
r = 10;
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);
clear kmMaxIter kmNumRep
elseif strcmp(mode,'random')
indSmp = randperm(nSmp);
marks = data(indSmp(1:p),:);
clear indSmp
else
error('mode does not support!');
end
.
.
[label,s] = kmedo(U',k);
end
the second function is
function Accuracy=yarbb(data,x)
for i=1:100
rng('default')
*[cluster_labels,s] = LSC(adj,x);*
coordinates=data;
Av=[coordinates; fliplr(coordinates)];
linindices = sub2ind(size(s), Av(:, 1), Av(:, 2))';
remain=setdiff(1:numel(s), linindices);
sim=s(remain);
similarity=unique(sim);
.
.
.
auc= (ndash + 0.5 * nddash)/(ndash+nddash+nn);
end
Accuracy = mean(auc)
we note that the second function call the first function in line 4,so i want to variables "p" ,"r" in first function to take values 2:10 and each time calculate accuracy(second function)i.e calculate first function at p=2,r=2 then calculate second function then in second time p=3,r=2 and calculate second function and so on.
Accepted Answer
More Answers (0)
Categories
Find more on Utilities for the Solver in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!