The stem plot is not shown in the figure

18 ビュー (過去 30 日間)
Badr Al-Sabri
Badr Al-Sabri 2022 年 11 月 16 日
コメント済み: Badr Al-Sabri 2022 年 11 月 16 日
The stem plot is not showing although the code should be correct,
Can you help me to figure what is the mistake I have made?
This is the script code:
%% CT signal
t = 0:0.01:2; % sample points from 0 to 2 in steps of 0.01
xt = sin(2*pi*t); % Evaluate sin(2 pi t)
subplot(2,1,1); % Two rows, one column, first plot
plot(t,xt,'b'); % Create plot with blue line
% Label axis
xlabel('t in sec');
ylabel('x(t)');
title('Plot of sin(2\pi t)'); % Title plot
%% DT signal
n = 0:1:40; % sample index from 0 to 40
xn = sin(0.1*pi*n); % Evaluate sin(0.1 pi n)
subplot(2,1,2); % Two rows, one column, second plot
Hs = stem(n,xn,'r','filled','marker size',4); % Stem-plot
% Label axis
xlabel('n');
ylabel('x(n)'); % Label axis
title('Stem Plot of sin(0.1\pi n)'); % Title plot

採用された回答

VBBV
VBBV 2022 年 11 月 16 日
t = 0:0.01:2; % sample points from 0 to 2 in steps of 0.01
xt = sin(2*pi*t); % Evaluate sin(2 pi t)
subplot(2,1,1); % Two rows, one column, first plot
plot(t,xt,'b'); % Create plot with blue line
% Label axis
xlabel('t in sec');
ylabel('x(t)');
title('Plot of sin(2\pi t)'); % Title plot
%% DT signal
n = 0:1:40; % sample index from 0 to 40
xn = sin(0.1*pi*n); % Evaluate sin(0.1 pi n)
subplot(2,1,2); % Two rows, one column, second plot
Hs = stem(n,xn,'r','filled','markersize',8); % delete the space betweeen words
% Label axis
xlabel('n');
ylabel('x(n)'); % Label axis
title('Stem Plot of sin(0.1\pi n)'); % Title plot
  2 件のコメント
VBBV
VBBV 2022 年 11 月 16 日
delete the space betweeen words marker and size in the function
Badr Al-Sabri
Badr Al-Sabri 2022 年 11 月 16 日
Thank you so much

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

その他の回答 (1 件)

cr
cr 2022 年 11 月 16 日
I don't think there is markersize attribute in stem(). Either do
stem(n,xn)
or replace stem() with plot()

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by