How to load multiple mat file in sequence without natsortfiles?

9 ビュー (過去 30 日間)
taimour sadiq
taimour sadiq 2024 年 12 月 24 日
編集済み: Matt J 2024 年 12 月 24 日
if three files in my directory file1.mat file2.mat & file13.mat
when i load it load in sequence
file1.mat
file13.mat
file.2mat
> Sort function not working for me
https://www.mathworks.com/matlabcentral/answers/2037626-how-to-load-all-mat-files-in-the-filenumber-wise-sequentially
  1 件のコメント
Stephen23
Stephen23 2024 年 12 月 24 日
編集済み: Stephen23 2024 年 12 月 24 日
"Sort function not working for me"
Did you download NATSORTFILES from here?:
Did you unzip it onto the MATLAB Search Path? (e.g. into the current directory)
Do you get an error message? If so, what is the complete error message?

サインインしてコメントする。

回答 (1 件)

Matt J
Matt J 2024 年 12 月 24 日
編集済み: Matt J 2024 年 12 月 24 日
F=sort("file"+(1:14)+".mat"); F=F(randperm(end)) %Unordered file list
F = 1x14 string array
Columns 1 through 11 "file2.mat" "file10.mat" "file12.mat" "file1.mat" "file9.mat" "file14.mat" "file8.mat" "file13.mat" "file6.mat" "file11.mat" "file5.mat" Columns 12 through 14 "file3.mat" "file7.mat" "file4.mat"
[~,is]= sort( str2double(extract(F,digitsPattern)) );
F=F(is) %list of files sorted
F = 1x14 string array
Columns 1 through 11 "file1.mat" "file2.mat" "file3.mat" "file4.mat" "file5.mat" "file6.mat" "file7.mat" "file8.mat" "file9.mat" "file10.mat" "file11.mat" Columns 12 through 14 "file12.mat" "file13.mat" "file14.mat"

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by