Effacer les filtres
Effacer les filtres

reading a file with fscanf returns too many rows

1 vue (au cours des 30 derniers jours)
Gil
Gil le 26 Juil 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 commentaires
Gil
Gil le 26 Juil 2013
Thanks Cedric Wannaz and dpb, I can't believe I missed it!
Cedric
Cedric le 26 Juil 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!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Text Data Preparation dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by