필터 지우기
필터 지우기

reading a file with fscanf returns too many rows

조회 수: 1 (최근 30일)
Gil
Gil 2013년 7월 26일
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
Gil
Gil 2013년 7월 26일
Thanks Cedric Wannaz and dpb, I can't believe I missed it!
Cedric
Cedric 2013년 7월 26일
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!

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by