How to import specific column from multiple ASCII files (543 files, .dat format) where each ASCII files are having 14 columns in it.

1 view (last 30 days)
Things to be noted that, the name of ASCII files are random text.

Answers (1)

Adithya Addanki
Adithya Addanki on 11 Jan 2016
Hi Ankit,
I understand that you are trying to import specific columns from multiple files. You may make use of the import data tool in MATLAB and generate script for use with multiple files.
To do this, you will need to press Import Data(under "Home" tab)-> Select a sample file-> then select the specific columns of interest-> Import Selection-> Generate Script
This action will generate a script for importing the columns from a specific file. Now, you may edit this script to automatically find the files with DAT extension in a particular directory and pass the names of files instead of hardcoded file name in the script.
For instance: t = dir('*.dat') % gives you list of dat files t(1) % struct of the attributes of first file t(2) % struct of the attributes of second file
I hope this helps.
Thank you,

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!