shengdai1
(Sheng Dai)
August 29, 2020, 11:09am
1
Why is the sinc function in Mathematica is different from Matlab
e.g. sinc(pi/2) in Matlab gives -0.1977
however in Mathematica it gives
Sinc[Pi/2] = -0.0544021
Also the plotting results were totally different.
In Matlab here is the code
clc
clear all
close all
t=linspace(-10,10,2000+1); t(end)=[];
y=sinc(t);
figure
hold on
plot(t,y)
/////////////////////////////////////////////////////
in Mathematica
Plot[Sinc[x],{x,-10,10}]
Because in Mathematica: Sinc[z] is equivalent to Sin[z]/z for z!=0, but is 1 for z=0.
A workaround:
x = Pi/2; Sinc[Pi*x] // N
(*-0.197651*)
Sin[Pi x]/(Pi x) // N
(*-0.197651*)
Plot[Sinc[Pi x], {x, -10, 10}, PlotRange -> All, AxesOrigin -> {-10, -0.4}]
Doing some minimal research might help, e.g. Wikipedia !
neils
(Neil Singer)
August 29, 2020, 11:38am
4
Mathematica uses radians as the input and Matlab uses a “Normalized” sinc function. Matlab has a unitless input and multiplies it by Pi to get radians. Matlab definition is Sin(pix)/(pi x).
Regards,
Neil