diff options
| author | leochanj105 <leochanj@live.unc.edu> | 2020-10-19 23:09:30 -0400 |
|---|---|---|
| committer | leochanj105 <leochanj@live.unc.edu> | 2020-10-20 02:40:39 -0400 |
| commit | f618466c25d43f3bae9e40920273bf77de1e1149 (patch) | |
| tree | 460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/common/toolbox/toolbox_basic/stella/getfnames.m | |
| parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) | |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/stella/getfnames.m')
| -rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/stella/getfnames.m | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/stella/getfnames.m b/SD-VBS/common/toolbox/toolbox_basic/stella/getfnames.m new file mode 100755 index 0000000..4990451 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/stella/getfnames.m | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | % function [fn,dn] = getfnames(direc,opt) | ||
| 2 | % Input: | ||
| 3 | % direc = directory | ||
| 4 | % opt = wildcat | ||
| 5 | % Output: | ||
| 6 | % fn = a cell with all filenames under direc and with opt | ||
| 7 | % dn = a cell with all directory names under direc and with opt | ||
| 8 | % For example, getfnames('19990910','*.jpg'); | ||
| 9 | % Set IS_PC according to your platform in globalenvar.m | ||
| 10 | |||
| 11 | % Stella X. Yu, 2000. | ||
| 12 | |||
| 13 | function [fn,dn] = getfnames(direc,opt) | ||
| 14 | |||
| 15 | if (nargin<1 | isempty(direc)), | ||
| 16 | direc = '.'; | ||
| 17 | end | ||
| 18 | |||
| 19 | if nargin<2 | isempty(opt), | ||
| 20 | opt = []; | ||
| 21 | end | ||
| 22 | |||
| 23 | fn = {}; | ||
| 24 | dn = {}; | ||
| 25 | |||
| 26 | cur_dir = pwd; | ||
| 27 | cd(direc); | ||
| 28 | s = dir(opt); | ||
| 29 | if isempty(s), | ||
| 30 | disp('getfnames: no data'); | ||
| 31 | return; | ||
| 32 | end | ||
| 33 | |||
| 34 | n = length(s); | ||
| 35 | i = 1; | ||
| 36 | j = 1; | ||
| 37 | for k=1:n, | ||
| 38 | if s(k).isdir, | ||
| 39 | dn{j,1} = s(k).name; | ||
| 40 | j = j + 1; | ||
| 41 | else | ||
| 42 | fn{i,1} = s(k).name; | ||
| 43 | i = i + 1; | ||
| 44 | end | ||
| 45 | end | ||
| 46 | cd(cur_dir) | ||
| 47 | %[fn{1:n,1}]=deal(s.name); | ||
