フィルターのクリア

reading a file with fscanf returns too many rows

2 ビュー (過去 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 Center および File ExchangeLow-Level File I/O についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by