Hello everyone. I define a Gama function which must had 4 inputs. If we entered more than 4 inputs it should say Error!. I must use the variables that taken from inside of the varargin to an equation like this fun= (sin(2*pi.*f.*(m-n).*T))/ 2*pi.*f.*(m-n).*T; but how can i name my variables? For example if i entered Gama(1,3,5,7) the first value should represents m ,the second value should represents n and the others represents f and t. How can i name them and use it into my function. Thanks for your help. Have a Good Day.
function Gama(varargin)if nargin<=4 disp("Number of input arguments: " + nargin) disp(varargin)else 'Error' f=varargin{1} m=varargin{2} n=varargin{3} T=varargin{4} if nargin<=4 fun= (sin(2*pi.*f.*(m-n).*T))/ 2*pi.*f.*(m-n).*T; t=1:1:100; figure plot(fun,t) xlabel('Omega') ylabel('Gamma') else 'Error! More Than 4 Inputs entered' end
Best Answer