Respectively, codes, matlab plot, and graphing site plot.
Even though I made same argument, matlab plot gives wrong plot. What's wrong? I need your help.

3 件のコメント

Walter Roberson
Walter Roberson 2023 年 5 月 13 日
The graphing site is clearly wrong: the red curve is just sinc() without any cos() component.
James Tursa
James Tursa 2023 年 5 月 13 日
Please post code as regular text highlighed by the CODE button. We can't run images.
민건 김
민건 김 2023 年 5 月 13 日
I figured out what's wrong. I thought sinc at matlab gives sin(x)/x but basically it gives sin(pi x)/pi x. Here, I wanna plot former one, which is unnormalized one, but I don't know how to, either.... Haha

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

 採用された回答

VBBV
VBBV 2023 年 5 月 13 日

0 投票

Delete pi from below line
% delete pi from the below line
a = (-4:0.001:4);
p = 10;
f = p*sinc(a) + cos(a)
f = 1×8001
-0.6536 -0.6569 -0.6602 -0.6634 -0.6667 -0.6699 -0.6732 -0.6765 -0.6797 -0.6830 -0.6862 -0.6895 -0.6928 -0.6960 -0.6993 -0.7025 -0.7058 -0.7091 -0.7123 -0.7156 -0.7189 -0.7221 -0.7254 -0.7287 -0.7319 -0.7352 -0.7384 -0.7417 -0.7450 -0.7482
plot(a,f)

5 件のコメント

민건 김
민건 김 2023 年 5 月 13 日
Thank you. It works but can you explain me why? I cant' find the reason.
Walter Roberson
Walter Roberson 2023 年 5 月 13 日
The cos still needs the pi
a = (-4:0.001:4)*pi;
p = 10;
f = p*sinc(a/pi) + cos(a)
f = 1×8001
1.0000 0.9975 0.9950 0.9925 0.9899 0.9874 0.9848 0.9822 0.9796 0.9771 0.9744 0.9718 0.9692 0.9666 0.9639 0.9613 0.9586 0.9559 0.9532 0.9505 0.9478 0.9451 0.9424 0.9396 0.9369 0.9341 0.9313 0.9285 0.9257 0.9229
plot(a,f)
VBBV
VBBV 2023 年 5 月 13 日
By definition sinc can be written as (sinx / x) , so if you apply in the equation, you would get a result as shown below,
% delete pi from the below line
a = (-4:0.001:4)*pi;
p = 10;
f = p*sin(a)./a + cos(a)
f = 1×8001
1.0000 0.9975 0.9950 0.9925 0.9899 0.9874 0.9848 0.9822 0.9796 0.9771 0.9744 0.9718 0.9692 0.9666 0.9639 0.9613 0.9586 0.9559 0.9532 0.9505 0.9478 0.9451 0.9424 0.9396 0.9369 0.9341 0.9313 0.9285 0.9257 0.9229
plot(a,f)
In your code, you have multiplied or included pi in x-vector, but did not divide it. The graph which you want to obtain is actually sin(pi*x)/ (pi*x)
Walter Roberson
Walter Roberson 2023 年 5 月 13 日
Note however
x = 0
x = 0
sinc(x)
ans = 1
sin(x)./x
ans = NaN
Stephen23
Stephen23 2023 年 5 月 13 日
編集済み: Stephen23 2023 年 5 月 13 日
"By definition sinc can be written as (sinx / x) "
Except in the field of digital signal processing where it is commonly defined as
sin(pi*x) / (pi*x)
which is the definition that SINC uses, SINC being part of the Signal Processing toolbox:
"In the context of digital signal processing, we often use an alternative form in which the independent variable is multiplied by π":
" The sinc function is defined as: sinc(a) = sin(πa)/(πa)":

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

タグ

質問済み:

2023 年 5 月 13 日

編集済み:

2023 年 5 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by