Home > Net >  matlab Not enough input arguments for Anonymous function
matlab Not enough input arguments for Anonymous function

Time:10-29

enter image description here

Why is that error popping up?

I would like to know why the input argument is lacking

Did I write the expression for x wrong?

The expression for x is enter image description here

I tried modifying the expression for x and also the range of fplot, but I couldn't.

my_function=@(x)my_function((-x.^2)-(5.*x)-3 (exp.^x))

my_function =

  function_handle with value:

    @(x)my_function((-x.^2)-(5.*x)-3 (exp.^x))

>> fplot(my_function,[-5:5])
Error using fplot
Invalid parameter '-5 -4 -...'.
 
>> fplot(my_function,[-5 5])
Warning: Error updating FunctionLine.

 The following error was reported evaluating the
 function in FunctionLine update: Not enough input
 arguments.
 
>> fplot(my_function,[-5,5])
Warning: Error updating FunctionLine.

 The following error was reported evaluating the
 function in FunctionLine update: Not enough input
 arguments.
 
>> fplot(my_function,[-5,5,1])
Error using fplot
Invalid parameter '-5  5  1'.
 
>> fplot(my_function,(-5,5))
 fplot(my_function,(-5,5))
                      ↑
Invalid expression. When calling a function or indexing
a variable, use parentheses. Otherwise, check for
mismatched delimiters.
 
>> fplot(my_function,[-5,5])
Warning: Error updating FunctionLine.

 The following error was reported evaluating the
 function in FunctionLine update: Not enough input
 arguments.
 


The issues to be addressed are:

Use the fplot function to plot the function over the range of x from -5 to  5.


CodePudding user response:

exp is not a value, it is a function, and you are providing no inputs (hence the error message). exp.^x should be replaced by exp(x)

  • Related