write_data_into_txt.m
来自「libsvm is a simple, easy-to-use, and eff」· M 代码 · 共 37 行
M
37 行
function write_data_into_txt(Z,C,filename)
% This function is to write Z and C into a text file, which will be used by SVM machine.
% size(Z)=[N_train, D] , D is the dimension of training data.
% size(C)=[N_train, 1] , C_train is the class label of Z.
D=size(Z,2);
ZZ=zeros(size(Z,1),2*D);
ZZ(:,2:2:end)=Z;
ZZ(:,1:2:end-1)= ones(size(Z,1),1)*(1:1:D);
A=[C,ZZ]; %%% size(A)=[N_train, 1 + 2*D]
for j=1:D
if j==1
string='%+i %i:%+6.4f';
else
string=[string ' %i:%+6.4f'];
end
end
string=[string '\n'];
fid=fopen(filename,'wt');
fprintf(fid, string, A');
fclose(fid);
fclose all;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?