How to plot signal with unit step?

조회 수: 17 (최근 30일)
Bilal  Siddiqui
Bilal Siddiqui 2015년 9월 15일
답변: Divine 2023년 11월 3일
I want to plot the following signal in matlab but I am not sure how to do this with the unit step response involved.
x[n] = ((4/5)^n)u[n]
-5 < n < 20

채택된 답변

Hamoon
Hamoon 2015년 9월 15일
You can use heaviside function:
n = -5:1:20;
x = ((4/5).^n).*heaviside(n);
stem(n,x)
Bet be aware heaviside(0)=0.5
  댓글 수: 3
Hamoon
Hamoon 2015년 9월 15일
you can also use this if you want to have u[0]=0:
n = -5:1:20;
myStep = @(n) (n>0);
x = ((4/5).^n).*myStep(n);
stem(n,x)
Hamoon
Hamoon 2015년 9월 15일
My Pleasure...

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Kamalika Saha
Kamalika Saha 2022년 1월 5일
n = -5:1:20;
x = ((4/5).^n).*heaviside(n);
stem(n,x)

Divine
Divine 2023년 11월 3일
n = -5:1:20;
x = ((4/5).^n).*heaviside(n);
stem(n,x)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by