Borrar filtros
Borrar filtros

reading a file with fscanf returns too many rows

1 visualización (últimos 30 días)
Gil
Gil el 26 de Jul. de 2013
Hi,
I'm reading a text file using fscanf that has the following format:
32 (number of columns - 5, the number of columns is 37)
448 (number of data rows)
448 data rows with 37 columns
I'm using the following simple function:
function [feat nb dim]=loadFeatures(file)
fid = fopen(file, 'r');
dim=fscanf(fid, '%f',1);
if dim==1
dim=0;
end
nb=fscanf(fid, '%d',1);
% feat = fscanf(fid, '%f', [5+dim, inf]);
feat = fscanf(fid, '%f', [5+dim, inf]);
fclose(fid);
end
Somehow, the returned "feat" is of size 37X3161? How can that be?
Any help will be highly valued as I'm quite stuck with this problem.
Thank you,
Gil
  8 comentarios
Gil
Gil el 26 de Jul. de 2013
Thanks Cedric Wannaz and dpb, I can't believe I missed it!
Cedric
Cedric el 26 de Jul. de 2013
Well, let me reassure you by saying that I spent a good 5 minutes looking for a coding issue, before I finally decided to count columns!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Text Data Preparation en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by