加载具有索引名称的文件

时间:2018-09-27 13:46:58

标签: matlab

我只想加载一个不同的文件,只是一个参数(温度)在变化。

例如:

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

我不知道如何为我的所有温度制作不同的“检测器”文件。 目前,我只写了所有不同的文件名。我有很多 预先谢谢你

1 个答案:

答案 0 :(得分:0)

需要更多信息来提供确切的解决方案,但是通常您可以使用dir来获取所需的文件名,然后将数据加载到单元格或其他容器中。

例如说我有一个要加载的Mat文件目录。

% 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

然后可以处理存储在单元格中的数据。每个文件都存储在单独的单元格中。 file1 = data{1,1};file3 = data{3,1}等。