How can I import a file.txt and extract data?
1 view (last 30 days)
Show older comments
Roberto Palmeggiani
on 25 Nov 2021
Commented: Roberto Palmeggiani
on 27 Nov 2021
I want to create a function.
The function has to read the file and create a matrix: the first column must contain the first column of numbers (the numbers after HIP). In the second and third coulmn i need the numbers into the square parenthesis (they are coordinates).
How can I do?
0 Comments
Accepted Answer
Stephen23
on 25 Nov 2021
opt = {'CollectOutput',true};
[fid,msg] = fopen('prova2.txt');
assert(fid>=3,'%s',msg)
hdr = fgetl(fid);
out = textscan(fid,'HIP%d[%d,%d]%[^\n\r]',opt{:});
fclose(fid);
out{:}
More Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!