I have written a function in MATLAB as follows,

function y= quadfunc(x)
% quadfunc.m is the file name
y=x;
y= quad('quadfunc',0,1)
end
When I pressed the green play button one error has appeared like this,
>>quadfunc
Error usins quadfunc(line 2)
Not enough input arguements.
Now please help.

Antworten (2)

ES
ES am 25 Sep. 2013
Bearbeitet: ES am 25 Sep. 2013

0 Stimmen

Yes .. quadfunc takes exactly one argument. Pass it.
Eq:
quadfunc(5)
You can call the function as above from MATLAB commandline.
If you want to run from editor, then code it to be interactive using
input
command or hard code the value of x.
Walter Roberson
Walter Roberson am 25 Sep. 2013

0 Stimmen

You have quad('quadfunc') within quadfunc.m . As quad() attempts to invoke the function it is given, it would try to invoke quadfunc, which would try to invoke quad, which would try to invoke quadfunc.... and so on.
Use a different file to hold the call to quad, and call upon that file rather than calling upon quadfunc

Diese Frage ist geschlossen.

Gefragt:

am 25 Sep. 2013

Geschlossen:

am 20 Aug. 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by