Mahdi Safarzadeh
Mahdi Safarzadeh

Reputation: 51

MATLAB Error - Undefined function for input arguments of type 'double'

Implementing this MATLAB function

function y=myfunc(x)
    y=x^2+5*x+6;
end

is resulting in the following error.

>>myfunc(5)
Undefined function 'myfunc' for input arguments of type 'double'

I'm new to MATLAB, and any help would be appreciated!

Upvotes: 1

Views: 5624

Answers (1)

umair ali
umair ali

Reputation: 1

You can get results by two methods in matlab

  1. call function and define function below
answer= myfunc(5)

function y=myfunc(x)

y=(x^2)+(5*x)+6;

end
  1. a) Second option is to make a new function file but name of function and file name should be same

so make a file name as myfunc and write you function code there

function y=myfunc(x)

y=(x^2)+(5*x)+6;

end
  • b) in separate file with any name you can call that function

answer= myfunc(5)

Upvotes: 0

Related Questions