code shows error in function

I am using following code to write text file.. This is the part of a function.. and it works...
fid = fopen(sprintf('Image%d.txt',imageNumber),'wt');
for j=1:length(y),
fprintf(fid,'%f %f\n',y(j),x(j));
end
Now when i am using following code to read the same file then it shows error..
why.?
C = textscan('Image%d.txt',imageNumber);

 採用された回答

Walter Roberson
Walter Roberson 2012 年 12 月 21 日

0 投票

You do not textscan() a file name: you textscan() a file identifier created by fopen()
fid = fopen(sprintf('Image%d.txt',imageNumber),'rt');
C = textscan(fid, '%f%f');
fclose(fid)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeText Data Preparation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by