简体   繁体   中英

How to use output values of one function as input of another MATLAB

How would I go about using and assigning the values of my getValidArgs output into the input of my processArgs function. At the moment I have been able to get it to work somewhat but when I go to use one of the assigned values n,mu or sigma it says that the value is undefined. I will attach my code and the question I am trying to complete.

Thanks for your help.

function [n, mu, sigma] = getValidArgs( varargin )
[n, mu, sigma] = processArgs( varargin );
end

function [n, mu, sigma] = processArgs( args)

%args cell array

% Number of elements in arg less than 3
if length( args)<3
error('Required input for n, mu and sigma not provided')
end

end

This should be what you are looking for:

function [n,mu,si] = getValidArgs(a,b,c)

[n,mu,si] = processArgs(a,b,c);

end
function processArgs(varargin)

if length(varargin)
    error('edagagag')
end

if isscaler(varargin{1})||iscalar(varargin{2})||isscalar(varargin{3})
else
    error('dagdgg')
end
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM