how can I plot a unit step function?

조회 수: 488 (최근 30일)
Seba.V
Seba.V 2019년 8월 22일
How can i plot a unit step function or a piecewise function in Matlab?
ie:
h(t)=u(t-2)-u(t-4)?
or another example:
h(t)={0 for t<0, 1 for 2<t<3, 0 for t>3
Also, how can i plot a periodic square wave with thresholds in matlab?
  댓글 수: 2
the cyclist
the cyclist 2019년 8월 22일
This sounds like homework. If so, show what you have tried so far, and ask some specific questions where you are stuck. If you have literally no idea where to even begin, I suggest you go back to your teacher and seek help.
Seba.V
Seba.V 2019년 8월 22일
t=0:0.001:4;
h=(t-2)-(t-4);
subplot(2,1,1)
plot(t,h)
Sorry, yes I am very new to it and just starting out. Dont want to bother you, just seeking advice that can make me underdatand, and yes i have very little idea to even where to begin and if you have any good books or any resources for beginners in signal processing and general MatLab functioning, or even on some fundamental coding techniques needed to suggest, it would be greatly appreciated.
heaviside was what I was looking for!
Many thanks for your support.

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

채택된 답변

Star Strider
Star Strider 2019년 8월 22일
The unit step function is also knoiwn as the heaviside step function.

추가 답변 (1개)

Ildeberto de los Santos Ruiz
Ildeberto de los Santos Ruiz 2021년 7월 19일
This is my proposal, I hope it helps you:
u = @(t) double(t>=0);
h = @(t) u(t-2)-u(t-4);
fplot(h,[0,5])

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by