Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I sort the filenames in order given by dir()? I cannot turn a structure into a character array which means I cannot use sort, any tiips?

1 回表示 (過去 30 日間)
Timothy Nsubuga
Timothy Nsubuga 2019 年 6 月 23 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
function frstarrv()
File_names = dir('*.csv'); %attain every waveform in the event folder
h = char(File_names);
j = sort(h);
numFiles = length(File_names);
incr = 1:numFiles;
for i = 1:numFiles %call graphData() for each waveform
file = File_names(i).name;
hold on
plus = incr(i);%needed to offset graphs for plotting
[pksa,l] = graphData(file,plus);
hold on
end
end
%end of firstarrv()***************************************************

回答 (2 件)

Walter Roberson
Walter Roberson 2019 年 6 月 23 日
https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2019 年 6 月 23 日
Hi,
You'd need to use this syntax for char() command: h = char(File_names.name);
With this, the command sort() sorts out the *.csv files in your current directory.
Good luck.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by