MATLAB Answers

0

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

Asked by Moris Bouja on 16 May 2018
Latest activity Answered by 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

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.

Tags

1 Answer

Answer by Ameer Hamza
on 16 May 2018

Here is read about how to batch process files in MATLAB: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F.

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.
end

  0 Comments

Sign in to comment.