% read feature
function [fea, lab] = readfeature(cn, vsize, varargin)
% read feature of multiple classes
% cn is the classnum
% vsize is the feature size
% varargin gives the file name list

fea = []; lab = [];
% read feature according to the class number
% if cn == 2, lab = 1,-1; else lab = 1:cn
if cn == 2
    fid = fopen(varargin{1}, 'r');
    f = fscanf(fid, '%f', [vsize inf]);
    fea = [fea, f];
    l = ones(1, size(f, 2)) * 1;                % class 1
    lab = [lab, l];
    fclose(fid);
    
    fid = fopen(varargin{2}, 'r');
    f = fscanf(fid, '%f', [vsize inf]);
    fea = [fea, f];
    l = ones(1, size(f, 2)) * -1;                % class -1
    lab = [lab, l];
    fclose(fid);
else
    for k=1:cn
        fid = fopen(varargin{k}, 'r');
        f = fscanf(fid, '%f', [vsize inf]);
        fea = [fea, f];
        l = ones(1, size(f, 2)) * k;                % class k
        lab = [lab, l];
        fclose(fid);
    end
end