autotextread
No License
A wrapper around textread() that generates the format string for you automatically (each column is numeric or string); puts data into a struct with fields named for the column names given by the header line of the file. Has worked with 36-column data file. Based heavily on Solution number 26207, but that requires you know how many columns, and their formats, and does not scale well to more than about 10 columns.
For a similar utility for spreadsheets rather than text files, see Michael Robbins' spreadsheet2structure , File ID # 8127
Syntax example:
[a,colnames]=autotextread('autotextread_samp.txt')
where the file contains the following:
daynum stuff Adjective
1 .25 slimy
2 .23 speedy
3 1.00 super
You get:
a =
daynum: [3x1 double]
stuff: [3x1 double]
Adjective: {3x1 cell}
colnames = 'daynum' 'stuff' 'Adjective'
Cite As
Andrew Ross (2024). autotextread (https://www.mathworks.com/matlabcentral/fileexchange/1674-autotextread), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | add reference to similar utility,
|