Attempt to execute SCRIPT varargin as a function

6 vues (au cours des 30 derniers jours)
Muhammad Jawad Sajid
Muhammad Jawad Sajid le 27 Sep 2020
I am trying to execute a function "pawn_model_evaluation" which is written by someone else. As you can see that it requires a function named "fun_test" as one of the inputs. My fun_test function is very simple which requires the sum of seven input values (variables) to have the output value. the function is as below:
function [y]=Jawad(x1,x2,x3,x4,x5,x6,x7)
y=[x1+x2+x3+x4+x5+x6+x7];
end
afterwards, I provide the values of x variables in the command window and also execute fun_test='Jawad'; in the command window. Afterwards, I run the function "pawn_model_evaluation" but this message shows up:
Attempt to execute SCRIPT varargin as a function:
C:\Program Files\MATLAB\R2018a\toolbox\matlab\lang\varargin.m
the "pawn_model_evaluation" function is given below:
function [YY, comp_time] = pawn_model_evaluation(fun_test,XX,varargin)
%
% This function evaluate a given model against the random samples generated
% by the PAWN_SAMPLING function.
% Usage:
% YY = pawn_model_evaluation(fun_test,XX)
% [YY ,compt_time] = pawn_model_evaluation(fun_test,XX)
% Input:
% XX = cell array of size (M,n). The element X{i,k} is the subsamples
% of input datapoints to compute the sensitivity of factor i in
% subsample k, and it is a matrix of size (NC,M).
% XX can be generated using the PAWN_SAMPLING function
% (see help pawn_sampling to learn more).
% fun_test = name of the function implementing the model (string)
%
% Output:
% YY = cell array of size (M,n). The element X{i,k} is the subsamples
% of output values to compute the sensitivity of factor i in
% subsample k, and it is a vector of size (NC,P)
% comp_time = total computing time for model evaluation (sec)
%
% NOTE: If the 'fun_test' function requires other arguments besides 'XX',
% they can be passed as optional arguments after 'X' (see function
% model_evaluation).
% This function is part of the SAFE Toolbox by F. Pianosi, F. Sarrazin
% and T. Wagener at Bristol University (2015).
% SAFE is provided without any warranty and for non-commercial use only.
% For more details, see the Licence file included in the root directory
% of this distribution.
% For any comment and feedback, or to discuss a Licence agreement for
% commercial use, please contact: francesca.pianosi@bristol.ac.uk
% For details on how to cite SAFE in your publication, please see:
% bristol.ac.uk/cabot/resources/safe-toolbox/
%%%%%%%%%%%%%%
% Check inputs
%%%%%%%%%%%%%%
if ~ischar(fun_test); error('''fun_test'' must be a string'); end
if exist(fun_test,'file')~=2; error('function ''%s'' does not exist',fun_test); end
%%%%%%%%%%%%%%%%%%
% Model evaluation
%%%%%%%%%%%%%%%%%%
if nargin > 2
NumExtraArg = length(varargin);
end
[M,n] = size(XX) ;
YY = cell(M,n);
tic
for i=1:M
for k=1:n
YY{i,k} = model_evaluation(fun_test,XX{i,k},varargin{1:NumExtraArg});
end
end
comp_time=toc;
  3 commentaires
Muhammad Jawad Sajid
Muhammad Jawad Sajid le 28 Sep 2020
the above mentioned issue is resolved. thanks

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by