Passing name-value arguments to a function that calls feval
Show older comments
Hello,
Is it possible to pass name-value arguments to a function that calls feval? If yes, what is the syntax? The problem looks like this:
% I want to pass any number of name-value pairs here
r = frun(@fA,argA1=2)
% ========================================================================
function r = frun(fh,varargin)
% Function that calls feval
r = feval(fh,varargin);
end
% ========================================================================
function resA = fA(namedArgs)
% Test function A
arguments
namedArgs.argA1 (1,1) double = 1
namedArgs.argA2 (1,1) double = 1
namedArgs.argA3 (1,1) double = 1
end
resA = namedArgs.argA1 + namedArgs.argA2 + namedArgs.argA3;
end
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Function Creation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!