⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sortxi.m

📁 支持向量机工具箱
💻 M
字号:
function [newX,newI]=sortxi(X,I,K)
% [newX,newI]=sortxi(X,I,K)
%
% SORTXI sorts the matrix X according to the vector I and
%   renumbers class labels so that first class has label 1,
%   second class has label 2, ... etc.
%
% Input:
%  X [DxK] contains K vectors which are D-dimensional.
%  I [1xK] contains K integers, each integer corresponds to a vector.
%  K [1x1] contains numner of different inetegers in I.
% 
% Output:
%  newX [DxK] vectors from X reordered according to newI. At first 
%    places there are vectors which have label 1, then 2, etc.
%  newI [1xK] sorted vector I and mapped to ordinal numbers.
%

% Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac
% (c) Czech Technical University Prague, http://cmp.felk.cvut.cz
% Written Vojtech Franc (diploma thesis) 02.01.2000
% Modifications
% 24. 6.00 V. Hlavac, comments polished.

newX=zeros(size(X));
newI=zeros(size(I));
cnt=0;
minClass=min(I);
class=minClass;
newLabel=1;
for i=1:size(K,2),

   while isempty(find(I==class)), class=class+1; end

   fres=find(I==class);

   for j=1:max(size(fres)),
      cnt=cnt+1;
      newX(:,cnt)=X(:,fres(j));
      newI(cnt)=newLabel;
   end

   class=class+1;
   newLabel=newLabel+1;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -