フィルターのクリア

Hi, I am new to MATLAB. I am not getting the plot .

2 ビュー (過去 30 日間)
Kshitija Bagde
Kshitija Bagde 2018 年 2 月 28 日
コメント済み: Jim Riggs 2018 年 2 月 28 日
I am trying to plot N=5; A=-20:5:20; B=(1/N)*(abs((sin((N*A)/2))/(sin(A/2)))); plot(A,B)
I am not getting any error but getting only one value for B. Help please. Thank You in advance

採用された回答

Chad Greene
Chad Greene 2018 年 2 月 28 日
You're doing vector operations, so use the ./ when calculating B like this:
B=(1/N)*(abs((sin((N*A)/2))./(sin(A/2))));
The . before operators such as .* is the difference between a cross product and a dot product, and the same logic follows for division and exponentials.
  1 件のコメント
Kshitija Bagde
Kshitija Bagde 2018 年 2 月 28 日
working. thank you

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

その他の回答 (1 件)

Jim Riggs
Jim Riggs 2018 年 2 月 28 日
Inside the abs function you are dividing two vectors. This is where the error is.
  2 件のコメント
Kshitija Bagde
Kshitija Bagde 2018 年 2 月 28 日
But when manually calculated, for every value A, there is different answer. Also not getting when abs is deleted
Jim Riggs
Jim Riggs 2018 年 2 月 28 日
You should review your Matlab introductory material for operation syntax. Matlab uses different syntax to determine when a matrix operation is to be performed (as you have specified) vs. a scalar operation (as Chad has shown in his answer). You need to be familiar with these concepts.

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by