why I get unintelligible text
Show older comments
I just want to read data from a txt file,why it's unintelligible text,may anybody can help me??? thx
code :
filename='test2.txt';
fileID=fopen(filename,'r');
formatSpec='%d %d %d %d %d %d %d %d %d %s';
size=[10,inf];
A=fscanf(fileID,'%d %d %d %d %d %d %d %d %d %s',size);
fprintf(formatSpec,A);
fclose(fileID);
________________________________________________________________
txt data :
0 213 1038 241 1072 10000 1 0 0 "Biker"
0 211 1038 239 1072 10001 1 0 1 "Biker"
0 211 1038 239 1072 10002 1 0 1 "Biker"
0 211 1038 239 1072 10003 1 0 1 "Biker"
0 211 1038 239 1072 10004 1 0 1 "Biker"
0 211 1038 239 1072 10005 1 0 1 "Biker"
0 211 1038 239 1072 10006 1 0 1 "Biker"
0 211 1038 239 1072 10007 1 0 1 "Biker"
____________________________________________________________
result:

5 Comments
madhan ravi
on 8 Apr 2019
Upload your text file.
wenhuan wu
on 8 Apr 2019
madhan ravi
on 8 Apr 2019
T = readtable('test2.txt');
table2cell(T)
amazing bro! but what wrong in my code?
Guillaume
on 8 Apr 2019
As was pointed out to me by Peter recently, converting the table to a cell array is not a good idea. It's going to use a lot more memory for no useful gain. Keep the data as a table.
madhan ravi
on 8 Apr 2019
Noted with care :)
Accepted Answer
More Answers (1)
wenhuan wu
on 8 Apr 2019
0 votes
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!