Home > data-import > supporting_functions > lib > sort_file_name_by_seq.m

sort_file_name_by_seq

PURPOSE ^

SYNOPSIS ^

function [sorted_list sorted_seq] = sort_file_name_by_seq(file_list, seq_pos_idx)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [sorted_list sorted_seq] = sort_file_name_by_seq(file_list, seq_pos_idx)
0002 if ~exist('seq_pos_idx', 'var')
0003     seq_pos_idx = -1;
0004 end
0005 
0006 n = length(file_list);
0007 
0008 % get file sequence No.
0009 seq = NaN(n, 1);
0010 for i=1:n
0011     fname = file_list(i).name;
0012     
0013     s = regexp(fname, '[_.]', 'split');
0014     seq(i) = str2double(s{end + seq_pos_idx});
0015 end
0016 
0017 [sorted_seq idx] = sort(seq);
0018 sorted_list = file_list(idx);
0019 
0020 end
0021

Generated on Tue 23-May-2017 03:00:58 by m2html © 2005