Question about import a .txt file into matlab
Show older comments
I'm trying to import a .txt data, but when i used the import data option, something goes wrong and does not appear the file that I want to analyse.
The file is attached. Thank you so much!
3 Comments
Bob Thompson
on 10 Oct 2019
What exactly goes wrong? What command are you using to do the import?
Johan Sebastian Diaz Tovar
on 10 Oct 2019
Bob Thompson
on 11 Oct 2019
I'm not sure about the exact error you're getting, but I would guess the error line is not reading because you have the row start line. In the textscan documentation the first three inputs are the file ID, the formatspec, and the number of repetitions you want to capture. The format spec you have specified for the error line returns a single cell which contains a series of strings for all individual lines of the file. For me, using the repetition number returned a blank cell with no data. I would suggest getting rid of that number (which I suspect is supposed to be the number of header lines).
Which bits of data are you trying to capture from the file? I see three integers, a comma, and two to three more integers, before a series of spaces with a 0 or -0 as the final characters. Are you looking to capture the numbers on either side of the comma? Or is that supposed to be one number, and the 0 is the second column?
Accepted Answer
More Answers (1)
prasanth s
on 10 Oct 2019
0 votes
you can use 'fopen' and 'fread' functions.
Categories
Find more on Spreadsheets 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!