필터 지우기
필터 지우기

plotting unit step function

조회 수: 14 (최근 30일)
David bondi
David bondi 2012년 4월 13일
Hi am trying to plot this unit step function u(t-1)-u(t-2)+u(2-t)-u(3-t)+u(t-3)-u(t-4) and really not sure where to start. I have tried doing a laplace transformations with no success, and setting boundary limits with nothing but errors and have even tried to use heaviside function.
Thank you

채택된 답변

Rick Rosson
Rick Rosson 2012년 4월 13일
Fs = 100;
dt = 1/Fs;
StartTime = -5;
StopTime = 15;
t = StartTime:dt:StopTime-dt;
x = (t>1) - (t>2) + (t<2) - (t<3) + (t>3) - (t>4);
figure;
stairs(t,x);
ylim([-1.2 1.2]);

추가 답변 (1개)

Richard Brown
Richard Brown 2012년 4월 13일
Or as an anonymous function:
f = @(t) (t > 1) - (t > 2) + (t < 2) - (t < 3) + (t > 3) - (t > 4);
t = linspace(-5, 5, 200);
stairs(t, f(t));

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by