0

I would like to load different files that have more or less the same just a parameter (temperature) is changing.

For example:

detector_temp = importdata('beginning name file' temp 'K_end name file.dat');

I don't know how to make different "detector" files for all my temperatures. For the moment I just write all the different file names. I have plenty. Thank you in advance

Paolo
  • 21,270
  • 6
  • 38
  • 69
  • Possible duplicate of [Matlab file name with zero-padded numbers](https://stackoverflow.com/questions/14213442/matlab-file-name-with-zero-padded-numbers) – Cris Luengo Sep 27 '18 at 15:29

1 Answers1

0

Need more information to provide an exact solution but generally you can use dir to get the filenames you want and then load the data into a cell or some other container.

For example say I have a directory of mat files I want to load.

% from the desired directory
files = dir('*.mat'); % get the files I want to load
fileNames = {files.name}'; % extract just the file name
data = cellfun(@load, fileNames, 'UniformOutput', 0); % load all the files into a cell

You can then work on the data that is stored in the cell. Each file is stored in a separate cell. So file1 = data{1,1};, file3 = data{3,1} and so on.

Matt
  • 2,554
  • 2
  • 24
  • 45