MATLAB: Help with Inner matrix dimensions must agree for equation below

inner matrix dimensions must agree

I am trying to solve for the function below using Simpson's rule. The function
y=b2fun(x)
y=(sinc(x-pi/3))*(exp(j*(pi*cos(x)+pi/6)));
However I keep getting the error "Inner matrix dimensions must agree."
How could i possibly get around this challenge?
Thanks.

Best Answer

If x is a vector, then your intermediate results from sinc, exp, and cos are also vectors. To multiply these results element-wise use .* instead of *
y =(sinc(x-pi/3)).*(exp(j*(pi*cos(x)+pi/6)));