code shows error in function

1 次查看(过去 30 天)
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Standard File Formats 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by