Passing name-value arguments to a function that calls feval
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Function Creation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!