Read text file with string
Show older comments
Hi all,
I have to read the file (inserted in attachment) and only need the numeric portion as a matrix(array). The extension of file is .TXK .
Thanks in advance
Accepted Answer
More Answers (1)
Guillaume
on 4 Mar 2020
Should work in R2016a:
filename = 'My2.TXK'; %using full path would be better
[fid, errmsg] = fopen(filename, 'rt');
assert(fid > 0, 'Failed to open "%s" due to error: %s', filename, errmsg);
data = cell2mat(textscan(fid, '%f%f%f', 'Delimiter', {'\t', ' '}, 'MultipleDelimsAsOne', true, 'HeaderLines', 1));
fclose(fid);
Categories
Find more on Text Files 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!