How to plot the graph for a given signal over a range of frequency

23 ビュー (過去 30 日間)
Saumya
Saumya 2023 年 2 月 3 日
編集済み: Sarvesh Kale 2023 年 2 月 3 日
How do I plot a discrete graph over the range of frequency given as [0 pi/8 pi/4 pi/2 pi] for the equation of signal x(n)=cos(w*n)

回答 (2 件)

KSSV
KSSV 2023 年 2 月 3 日
w = [0 pi/8 pi/4 pi/2 pi] ;
n = 1 ;
x = cos(w*n) ;
plot(w,x)

Sarvesh Kale
Sarvesh Kale 2023 年 2 月 3 日
編集済み: Sarvesh Kale 2023 年 2 月 3 日
Hi Saumya,
I am assuming you are trying to visualize different frequency discrete cosine waves, following is the code snippet that does this
w = [0 pi/8 pi/4 pi/2 pi] ;
n=1:20; % length of discrete signal
figure ; % makes a figure object
subplot(5,1,1);
for i=1:5
x= cos(w(i)*n); % i will select a frequency from w
subplot(5,1,i); % to plot on different plots inside same figure
stem(n,x,'LineWidth',2); % stem function is used for discrete signals
title([' w = ',num2str(w(i))]);
hold on ; % draw on same plot
end
the documentation of stem can be found in the following link https://in.mathworks.com/help/matlab/ref/stem.html
Hope this answers your queries

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by