Dea*_*nes 17 iteration matlab function
是否有可能在MATLAB中迭代一系列函数?我正在尝试测试不同的径向基函数,这似乎是最好的方法.
gno*_*ice 23
vec = 1:5; % A sample vector of values
fcnList = {@max, @min, @mean}; % Functions to apply to the vector
nFcns = numel(fcnList); % Number of functions to evaluate
result = zeros(1, nFcns); % Variable to store the results
for iFcn = 1:nFcns
result(iFcn) = fcnList{iFcn}(vec); % Get the handle and evaluate it
end
Run Code Online (Sandbox Code Playgroud)
如果你想定义自己的功能,你可以这样做,继续gnovice的回答:
funcList = {@(x, y) (x - y), @(x, y) (x + y)}
Run Code Online (Sandbox Code Playgroud)