filefun: Apply a function to files

版本 1.0.0.0 (5.4 KB) 作者: Jerker Wagberg
Adds multi-file functionality to functions handling only single files.
3.7K 次下载
更新时间 2007/2/16

无许可证

编者注: This file was a File Exchange Pick of the Week

FILEFUN is created in the same spirit as e.g. CELLFUN, in that it repeatedly calls the same function FUN with different arguments, in this case filenames. It will then collect the output(s) of the function into concatenated arrays of the same type as FUN delivers, or encapsulated individually in cell arrays.

The filename argument to FILEFUN may contain wildcards(*) and FILEFUN may optionally traverse subdirectories recursively.

FILEFUN can also be called without the FUN argument, turning it into a recursive wildcard file finder.

See 'help filefun' for extensive help and more examples.

Examples:

Open all figure files in current directory:

filefun(@openfig,'*.fig')

Pick a couple of image files and compute their mean RGB values:

pth=fullfile(matlabroot, 'toolbox', ...
'matlab', 'demos', 'html', filesep);
[filenames,pathname]=uigetfile('*.png','Pick files', ...
pth,'MultiSelect', 'on');
fun=@(fn) squeeze(mean(mean(imread(fn))))';
mn=filefun(fun,strcat(pathname,filenames))

引用格式

Jerker Wagberg (2024). filefun: Apply a function to files (https://www.mathworks.com/matlabcentral/fileexchange/9723-filefun-apply-a-function-to-files), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R14SP3
兼容任何版本
平台兼容性
Windows macOS Linux
致谢

参考作品: parse_pv_pairs

启发作品: Bl

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.0

Upload problems resulted in not uploading new code.