且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Matlab:引用一组m文件中的函数

更新时间:2023-02-26 14:36:31

你可以使用 str2func 创建一个每个.m文件的函数句柄

You can use str2func to create a function handle to each of the .m files

% Add the folder to your path
addpath(CM_inverse_folder_path)

function_list = {'cI_0001.m', 'cI_0002.m'};

% Remove the extensions
[~, function_list] = cellfun(@fileparts, function_list, 'UniformOutput', false);

for k = 1:n
    func = str2func(function_list{k});
    conformal = maketform('custom', 2, 2, [], func, []);
    T = imtransform(C, conformal, ...);
    imwrite(T, ...);
end

% Remove the folder from the path
rmpath(CM_inverse_folder_path)