フォルダ内の複数枚存在する画像の操作
Afficher commentaires plus anciens
MATLABを使って複数枚画像が入っているフォルダの中から更新日時が一番新しい画像のみを読み込みたいです。 直接新しい画像のみ読み込めない場合はフォルダの中をソートしても構いません。 なにか手段はありますか? よろしくお願い致します。
Réponse acceptée
Plus de réponses (1)
Tohru Kikawada
le 30 Mar 2018
% ファイル一覧取得
listing=dir(fullfile(matlabroot,'toolbox','matlab','icons'));
% 構造体からtable型に変換
filesTable = struct2table(listing);
% フォルダは除去
validFilesTable = filesTable(~filesTable.isdir,:);
% datenum(日付を表す数値)で降順にソート
sortedFilesTable = sortrows(validFilesTable,...
find(strcmp(validFilesTable.Properties.VariableNames,'datenum')),'descend');
% 上位10個を取り出す
disp(sortedFilesTable(1:10,[1 3]));
実行結果
name date
____________________________________ _____________________
'plotpicker-geobubble.png' '19-7-2017 05:49:38'
'appcontainer.ico' '16-2-2017 00:48:04'
'plotpicker-arx.png' '19-5-2016 23:06:20'
'plotpicker-n4sid.png' '19-5-2016 23:06:20'
'plottype-errorbar-horizontal.png' '12-4-2016 08:11:32'
'plottype-errorbar.png' '12-4-2016 08:11:23'
'plotpicker-errorbar-horizontal.png' '12-4-2016 08:11:06'
'plotpicker-errorbar.png' '12-4-2016 08:10:57'
'plotpicker-graphplot.png' '01-10-2015 03:24:07'
'plottype-graphplot.png' '01-10-2015 03:22:28'
Catégories
En savoir plus sur ファイルの操作 dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!