converting this LIBSVM data to a normal matrix?
1 view (last 30 days)
Show older comments
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!
1 Comment
Answers (0)
See Also
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!