Generating a data sequence that results in this graph

Hello people,
Been racking my brain with this one. I need to write a data sequence that results in the graph below. I think I'm supposed to somehow use the unit step function and discrete delta function. I just have a really hard time figuring out how to start and what functions to manipulate.

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 5 日
編集済み: Ameer Hamza 2020 年 11 月 5 日

1 投票

Yes, unit step can be used here:
t = -10:10;
u_step = @(x) 1*(x>=0);
y = u_step(t+2) - u_step(t-5);
stem(t, y)

3 件のコメント

xRah
xRah 2020 年 11 月 5 日
How can I make it so that the end points don't touch the end of the plot?
xRah
xRah 2020 年 11 月 5 日
Nevermind, I realized its using the axis([]) command
Ameer Hamza
Ameer Hamza 2020 年 11 月 5 日
yes, xlim() and axis(), both will work here.

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

その他の回答 (1 件)

KSSV
KSSV 2020 年 11 月 5 日

1 投票

x = -5:1:10 ;
y = zeros(size(x)) ;
y(x > -3 & x < 6) = 1 ;
stem(x,y)

1 件のコメント

xRah
xRah 2020 年 11 月 5 日
Thanks again for your clarification!

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

カテゴリ

タグ

質問済み:

2020 年 11 月 5 日

コメント済み:

2020 年 11 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by