フィルターのクリア

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 Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by