converting this LIBSVM data to a normal matrix?

조회 수: 1 (최근 30일)
Desiree
Desiree 2020년 4월 24일
댓글: Shishir Singhal 2020년 4월 30일
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
Shishir Singhal
Shishir Singhal 2020년 4월 30일
Could you please state the error related to this solution ?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by