MATLAB: Not enough input arguments.

not enough input arguments

I am really new to use Matlab, can somebody help me?
Write a function in Matlab that generates the output y(t):
I did not study Matlab before, but I have to use Matlab to solve EE question. The following is my cord.
Please help me:
function u1=unit_step(x)
if x>=0
u1=1;
else
u1=0; end
function u2=unit_step(x)
if x>=t
u2=0;
else
u2=1; end
f = @(x) (x-t).*exp(x-t).*u1.*x^2.*exp(-x).*sin(x).*u2
Q = integral(f,-Inf,Inf)
———————Error using HW2_7 (line 2) Not enough input arguments.

Best Answer

I try not to do too many homework problems here because in a former life I was a college professor, and I think it's bad for the student just to hand them answers. But I think I should explain the error message.
When you have a function defined in a MATLAB file (ending in .m or .p), then when referring to the function, you must use @, e.g.
Q = integral(@f,-Inf,Inf)
The @ symbol tells MATLAB that you're referring the function, so it won't try to evaluate it immediately and pass the return values into the function.
If, OTOH, you have a function defined as an anonymous function e.g.
f = @(x)sin(x+2)
then you can refer to it by the name of the variable that is "holding" the anonymous function,
Q = integral(f,-Inf-Inf)
Related Question