필터 지우기
필터 지우기

Compare data in excel to folder location mat files.

조회 수: 1 (최근 30일)
sc1991
sc1991 2017년 9월 12일
편집: KL 2017년 9월 12일
Hi! so I have a list of mat files that I want to extract to separate folder location. The list is in excel sheet and the mat files are stored in the windows folder, is there a way that I can compare the name in excel sheet with the files in the folder location and for every positive match extract the file and save it to a new folder.

답변 (1개)

KL
KL 2017년 9월 12일
편집: KL 2017년 9월 12일
[~,filenames,~]=xlsread('your_excel_file.xls');
folderInfo = dir('your_folder/*.mat');
folder_filenames = {folderInfo.name};
for iFile=1:numel(filenames)
ind = 0;
ind=find(ismember(folder_filenames,filenames{iFile}));
if(ind~=0)
S(iFile).data=load(folder_filenames{iFile});
% here you could save S(iFile).data in whatever format you want to
% export and save it in different folders.
% save your target folder names in a cell array and use them
% using indexing
ind = 0;
end
end

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by