converting this LIBSVM data to a normal matrix?

1 visualización (últimos 30 días)
Desiree
Desiree el 24 de Abr. de 2020
Comentada: Shishir Singhal el 30 de Abr. de 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!
  1 comentario
Shishir Singhal
Shishir Singhal el 30 de Abr. de 2020
Could you please state the error related to this solution ?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by