Azzera filtri
Azzera filtri

converting this LIBSVM data to a normal matrix?

3 visualizzazioni (ultimi 30 giorni)
Desiree
Desiree il 24 Apr 2020
Commentato: Shishir Singhal il 30 Apr 2020
Hello,
I need to convert this LIBSVM data in form of struct with 2 fields to a normal matrix 8192x12.
I've found this here online:
function y=svm2mat(s)
% Usage: y=svm2mat ('filename')
clc
fid = fopen(s);
i=1;
while ~feof(fid) % not end of the file
s = fgetl(fid); % get a line
s1=[]; j=1;
while (j<=length(s))
while ( s(j)~=' ') && (j<length(s))
s1=[s1 s(j)];
j=j+1;
end
j=j+1;
s1=[s1 ' '];
while ( (j<length(s)) && (s(j)~=':') )
j=j+1;
end
j=j+1;
end
s2=str2num(s1) ;
if (i==1)
yy=zeros(1,length(s2));
end
yy=[yy,s2];
i=i+1;
end
yy(1,:)=[];
y=yy;
but it doesn't work for me.
Help is greatly appreciated!

Risposte (0)

Categorie

Scopri di più su Data Type Conversion in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by