classif.m
上传用户:lzb_9569
上传日期:2013-05-03
资源大小:5k
文件大小:0k
- function classification = classif(Ytrain, Ytest)
- % classification = classify(Ytrain, Ytest)
- %
- % Given the train matrix Ytrain and the test matrix Ytest,
- % this function returs a vector classification, where
- % for Ytest(:, a), the nearest element of Ytrain is
- % Ytrain(:, classification(a)).
- distances = dist(Ytrain', Ytest);
- classification = zeros(size(Ytest,2),1);
- for a=1:size(Ytest,2),
- aux = find(distances(:,a)==min(distances(:,a)));
- classification(a) = aux(1);
- end