hello everyone
i have a problem with the function sinc (i'm not so expert i started to use mathlab 3 months ago) and i wrote this:
x = 0:pi/100:2*pi;
y=sinc(x);
but i have an error:
Undefined function 'sinc' for input arguments of type 'double'.
someone can help me? thanks

 採用された回答

Birdman
Birdman 2020 年 3 月 27 日
編集済み: Birdman 2020 年 3 月 27 日

2 投票

Adapt its formula as follows:
x = 0:pi/100:2*pi;
y=sin(pi*x)./(pi*x);%sinc function
plot(y)

7 件のコメント

Jack
Jack 2020 年 3 月 27 日
It's also perhaps worth stating that some people (e.g. physicists) define as opposed to (which is more commonly used in the signal processing community).
Birdman
Birdman 2020 年 3 月 27 日
The OP can adapt the formula according to the need I guess. My aim was to give the idea on implementation.
dert sgt
dert sgt 2020 年 3 月 27 日
編集済み: dert sgt 2020 年 3 月 27 日
thanks to everyone so it's imposible to use sinc(x)? because it's easier for example or something similar
dert sgt
dert sgt 2020 年 3 月 27 日
yes jack someone uses
Birdman
Birdman 2020 年 3 月 27 日
Actually you should be able to use sinc(x) function but I guess you do not have signal processing toolbox or symbolic math toolbox which is required to use sinc(x). So, we have implemented the function according to its formula.
x = 0:pi/100:2*pi;
y=sin(pi*x)./(pi*x);%sinc function
plot(y)
or
x = 0:pi/100:2*pi;
y=sin(x)./x;%sinc function
plot(y)
Jack
Jack 2020 年 3 月 27 日
While the singal processing toolbox has sinc() defined explicitly, you can always create a function that does this -- e.g. put the following in a file called sinc.m somewhere in your current path (or in ~/Documents/MATLAB/ or My Documents\MATLAB\)
function out = sinc(x)
% Deal with the removable singularity at 0 explicitly.
out = sin(x)./x;
out(x == 0) = 1;
end
dert sgt
dert sgt 2020 年 3 月 27 日
thanks so much again you're fantastic!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2019b

質問済み:

2020 年 3 月 27 日

編集済み:

2020 年 3 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by