MATLAB Answers

how can i import many file into one file.mat?

1 view (last 30 days)
Moris Bouja
Moris Bouja on 16 May 2018
Answered: Ameer Hamza on 16 May 2018
i have many files.dat for exp test1.dat and test2.dat .. test10.dat i want import all files in one file data.mat
  1 Comment
Rik on 16 May 2018
So apparently you solved your other question? We don't know anything about what your files contain, what format they are or anything else. I don't know about other frequent contributors here, but I'm not a mind reader.
Have a read here and here. It will greatly improve your chances of getting an answer.

Sign in to comment.

Answers (1)

Ameer Hamza
Ameer Hamza on 16 May 2018
Here is read about how to batch process files in MATLAB:
Here is a general idea. You can read the content of your file one by one, in a for loop, using either fileread(), textscan, tableread(), csvread() and several other function available in MATLAB. Which function to use depends on the content of your file. Then after reading one file, convert it to a desirable format and save it a cell array.
files = dir('*.dat')
data = cell(1, length(files);
for i=1:length(files)
filename = files(i).name
% read filename using an appropriate function depending on your data.
data{i} = processedData; % here processed data obtained after reading the file.


Community Treasure Hunt

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

Start Hunting!