Check for missing argument or incorrect argument data type in call to function 'sinc'.

I am trying to plot this problem:
However, I am encountering the error in the title whenever i try to plot it. Here is my code so far (I am still at a)):
function labactivity52()
[x,y]=meshgrid(-8:0.5:8);
z=sinc(sqrt((x.^2)+(y.^2)));
mesh(x,y,z), xlabel('x'), ylabel('y'), zlabel('z'), title('Surface Mesh Plot')
end
Whenever I try to run the function to see its 3D plot, I encounter this line:
Check for missing argument or incorrect argument data type in call to function 'sinc'.
Error in labactivity52 (line 3)
z=sinc(sqrt((x.^2)+(y.^2)));
What am I doing wrong? Is the given equation wrong?

 Accepted Answer

The code works for me. You might have a sinc.m of your own that is interfering. Check
which -all sinc
You might see
/Applications/MATLAB_R2021a.app/toolbox/signal/signal/sinc.m
/Applications/MATLAB_R2021a.app/toolbox/signal/signal/@tall/sinc.m % tall method
/Applications/MATLAB_R2021a.app/toolbox/symbolic/symbolic/@sym/sinc.m % sym method
If you see your own function or a third-party toolbox function, then you might need to rename or delete something.

3 Comments

I ran
which -all sinc
And this is the only one that showed up:
\MATLAB\R2020b\toolbox\symbolic\symbolic\@sym\sinc.m % sym method
Is that what's supposed to come out? I notice that only one showed up in mine compared to your three.
I apologize for commenting again but I opted to use the form (sin x)/x instead of sinc (x) and managed to get my code to work now. Thank you for taking the time out of your day to help me fix my problem!
Be careful: sinc() is not sin(x)/x, it is sin(pi*x)/(pi*x) in MATLAB.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!