[英]load files from two different folders in matlab
Hi and I am little bit new in matlab. 您好,我在Matlab中有点陌生。 I have two different folders in my laptop, each one contains about 400 different files.
我的笔记本电脑中有两个不同的文件夹,每个文件夹包含约400个不同的文件。 I want to load all these files (400 from first folder and 400 from second folder), I tried like that but doesn't work:
我想加载所有这些文件(第一个文件夹中的400个文件,第二个文件夹中的400个文件),我尝试这样做,但不起作用:
folder1=('E:\results\1\');
folder2=('E:\results\2\');
data=load([folder1,'*.m']);
data1=load([folder2,'*.m']);
and then I want to take first file from folder1 and subtracted from first file from folder1 and save it in new folder. 然后我要从folder1提取第一个文件,并从folder1的第一个文件中减去,然后将其保存在新文件夹中。 and do that for all other files ... etc can some expert give me any suggerstion!!
并针对所有其他文件执行此操作...等一些专家可以给我任何建议!! thanks in advance.
提前致谢。
Pretty sure load
takes one file at a time. 可以肯定,
load
需要一个文件。 Try a simple variant like this: 尝试这样的简单变体:
folder1=('E:\results\1\');
folder2=('E:\results\2\');
files1 = dir( [folder1,'*.m'] );
files2 = dir( [folder2,'*.m'] );
data = cell(length(files1),1); % I don't know what's in the mat files, but let's start with a cell array
data1 = cell(length(files2),1);
for ii=1:length(files1)
data{ii} = load(fullfile(folder1,files1(ii).name));
end
for ii=1:length(files2)
data1{ii} = load(fullfile(folder2,files2(ii).name));
end
There are other, more one liner ways, but this is a fairly pedantic. 还有其他一种以上的班轮方式,但这是一个很老套的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.