Multi-tool- simply reuse your code over and over.
Most of us, Matlab people are generating functions. Some of those functions are designed to work with a file (image, video, audio, data etc…). And then, we need to apply it to another file, and another one. So we either do it manually, or we are writing a higher level function with a loop which calls our single-file function.
And this happens a lot. And thus we do this non creative task a lot, and that’s frustrating, right?
So I have written this function which will change the situation. Now, once you have a function that is designed to work on a file, all you need in order to apply it to several files (or a directory with files) is to use my apply_func_2_files_list function. You can specify the files/directory name as a function argument, or via GUI Files Explorer. You can specify any function specific parameters, using the “PARAMS” keyword.
Here is the documentation (from .m file):
% function crop_video_files_list(varargin)
%
% Functional purpose: This function applies some user defined function to a list of files (or a directory with files).
% This will allow the user to apply same operation to several files in a single command.
%
% Input arguments (defaults exist):
% applied_func_h- function handle to the function which will be applied to all files in list/directory.
% The function to which applied_func_h points to is expected to:
% 1) Operate on files, using thir file name (full path+name+extension)
% 2) The file_name is the first input parameter.
% 3) The function is expected to return resulting file (or nothing), so a list of resulting can be formed and
% returned by apply_func_2_files_list.m. This files list can be used, in turn as inputs in further processing...
% 4) The rest parameters the function needs will be specified after the key string 'PARAMS'. The above parameters
% will be used as inputs for applied_func_h, and will be thus used with all files in files_dir or with all
% input_files_list.
%
% files_dir- a directory including video files to be cropped. If specified, input_files_list will be constructed
% from all files in files_dir
%
% input_files_list- a list (cell array) of video files whose black sorrounding will be renoved (cropped out) by
% the function.
%
% GUI_menus_flag- when set to be true allowes the user to choose input files or directory with files via GUI
% dialogs
%
% Output Arguments:
% output_files_list- list of resulting files (assuming applied_func_h returns resulting file name).
%
% Issues & Comments: Note that the applied function fed with inputs after 'params' string of inputs to this, mother
% function, which may result in errors.
%
% Author and Date: Nikolay S. 7/12/2010.
% Last update: Nikolay S. 25/01/2011.
Comment in case of problems or improvement suggestions, I’ll try to fix.
Enjoy!
Citation pour cette source
Nikolay S. (2024). Multi-tool- simply reuse your code over and over. (https://www.mathworks.com/matlabcentral/fileexchange/30178-multi-tool-simply-reuse-your-code-over-and-over), MATLAB Central File Exchange. Extrait(e) le .
Compatibilité avec les versions de MATLAB
Plateformes compatibles
Windows macOS LinuxCatégories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Découvrir Live Editor
Créez des scripts avec du code, des résultats et du texte formaté dans un même document exécutable.
Version | Publié le | Notes de version | |
---|---|---|---|
1.0.0.0 |