Originally Posted by

**woody198403** Hi all,

I'm trying to use the built-in MATLAB function *quad *to integrate the following function :

$\displaystyle \int_{0}^{2\pi}\ x * sin (x) \ dx $ but its not working for me.

Now when I use the quad function to evaluate

$\displaystyle \int_{0}^{2\pi}\ x \ dx $ I get the correct answer.

When I use the quad function to evaluate

$\displaystyle \int_{0}^{2\pi}\ sin (x) \ dx $ I get the correct answer.

but when I use the quad function to evaluate

$\displaystyle \int_{0}^{2\pi}\ x * sin (x) \ dx $

I get the output

??? Error using ==> mtimes

Inner matrix dimensions must agree.

Error in ==> myfun at 7

y = sin(x) * x ;

Error in ==> quad at 77

y = f(x, varargin{:});

where myfun is the mfile I wrote .........

function y = myfun(x)

y = sin(x) * x ;

Also this is what I type into the MATLAB command window when I try and use the quad function

Q = quad(@myfun,0,(2*pi))

What am I doing wrong here? Im no expert in MATLAB and Im not sure how to get around this.