Blitzkayir
Blitzkayir

Reputation: 67

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

Upvotes: 0

Views: 240

Answers (1)

Brian Goodwin
Brian Goodwin

Reputation: 391

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

Upvotes: 2

Related Questions