필터 지우기
필터 지우기

I want to draw this step function by script code.

조회 수: 3 (최근 30일)
Sol Elec
Sol Elec 2022년 8월 27일
댓글: Chunru 2022년 8월 29일

답변 (2개)

Chunru
Chunru 2022년 8월 27일
편집: Chunru 2022년 8월 29일
t = linspace(0,11)';
x = square(t*0.25*2*pi);
min(x)
ans = -1
plot(t,x)
ylim([-1.1 1.1])
% Manually specify the points
t = [0 5 5 7 7 9 9 10];
x = [0 0 1 1 -2 -2 1 1];
figure
plot(t, x);
box on
grid on
ylim([-2.2 1.2])
  댓글 수: 3
Chunru
Chunru 2022년 8월 27일
Then you specify time and amplitude as two vectors.
Chunru
Chunru 2022년 8월 29일
See the update.

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


Sam Chak
Sam Chak 2022년 8월 27일
I'll show you the basic concept of how to construct this 5-sec delayed square wave.
t = linspace(0, 6, 601); % 11 minus 5-sec delayed, need to generate data for nett 6 seconds
f = (2*pi)/4 % angular frequency with a period of 4 seconds
x = sin(f*t); % base function for the signum function to switch
y = 3/2*sign(x) - 1/2; % square wave function
plot(t+5, x, t+5, y) % 5-sec delayed
grid on, xlim([0 12]), ylim([-3 2]), xlabel('t'), ylabel('y(t)')

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by