Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在matlab中读取文件夹中的所有pcd文件_Matlab - Fatal编程技术网

在matlab中读取文件夹中的所有pcd文件

在matlab中读取文件夹中的所有pcd文件,matlab,Matlab,我有一个文件夹,其中包括1000个pcd文件(a1,…,a1000)。我想在matlab中循环读取它们,并将它们存储在单独的矩阵中(mat1,…,mat1000) 例如(作为伪代码) 我该怎么做呢?这很有用: 您可以使用以下代码循环浏览文件夹中具有特定扩展名的所有文件: myFolder = 'C:\Users\...'; %The path to the folder which contains the files filePattern = fullfile(myFolder, '*.pc

我有一个文件夹,其中包括1000个pcd文件(a1,…,a1000)。我想在matlab中循环读取它们,并将它们存储在单独的矩阵中(mat1,…,mat1000)

例如(作为伪代码)

我该怎么做呢?

这很有用:

您可以使用以下代码循环浏览文件夹中具有特定扩展名的所有文件:

myFolder = 'C:\Users\...'; %The path to the folder which contains the files
filePattern = fullfile(myFolder, '*.pcd'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
    baseFileName = theFiles(k).name;
    fullFileName = fullfile(theFiles(k).folder, baseFileName);
    % Now do whatever you want with this file name
    % A{k} = pcread(fullFileName)
end
要将它们存储在单独的矩阵中,可以使用单元格数组。

这非常有用:

您可以使用以下代码循环浏览文件夹中具有特定扩展名的所有文件:

myFolder = 'C:\Users\...'; %The path to the folder which contains the files
filePattern = fullfile(myFolder, '*.pcd'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
    baseFileName = theFiles(k).name;
    fullFileName = fullfile(theFiles(k).folder, baseFileName);
    % Now do whatever you want with this file name
    % A{k} = pcread(fullFileName)
end

要将它们存储在单独的矩阵中,可以使用单元格数组。

读取文件所使用的特定功能取决于文件格式(对不起,我不知道PCD格式)。至于创建这1000个变量,这通常是个坏主意。最好使用多维数组或单元格数组,这样就不用
mat234
而是使用
mat(:,:,234)
mat{234}
读取文件的特定函数取决于文件格式(对不起,我不知道PCD格式)。至于创建这1000个变量,这通常是个坏主意。最好使用多维数组或单元格数组,这样就不用
mat234
而是使用
mat(:,:,234)
mat{234}