How to draw the delta signal in matlab

조회 수: 53 (최근 30일)
Juman Saleh
Juman Saleh 2023년 3월 27일
답변: Carlos M. Velez S. 2025년 7월 24일
I was trying to draw but I wasn't able to

답변 (3개)

the cyclist
the cyclist 2023년 3월 27일
편집: the cyclist 2023년 3월 27일
Do you mean the Dirac delta function? If so, then dirac might help you.
Also, if you do mean the Dirac delta, I hope you realize that it can't truly be "drawn", because it goes to infinity. It can be represented somehow (e.g. by drawing an arrow at the x location where the Delta is).
  댓글 수: 1
Juman Saleh
Juman Saleh 2023년 3월 28일
i know the function but how to plot d(t-1)

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


Star Strider
Star Strider 2023년 3월 28일
The function normally will not plot in MATLAB because it has infinite amplitude and infinitesimal width.
So it is necessary to approximate it in ordfer to plot it —
t = linspace(0, 2, 21);
Delta = dirac(t - 1)
Delta = 1×21
0 0 0 0 0 0 0 0 0 0 Inf 0 0 0 0 0 0 0 0 0 0
idx = Delta == Inf;
Delta(idx) = 1;
figure
stem(t, Delta, 'filled')
axis('padded')
.

Carlos M. Velez S.
Carlos M. Velez S. 2025년 7월 24일
If you want to apply the Dirac delta function in simulation to continuous-time systems, the following code is enough:
function y = delta_dirac(u)
[n,m] = size(u);
if max(n,m) ==1
dt = 1e-6; % Define a small time increment for the delta function
else
dt = u(2) - u(1);
end
y = zeros(n,m);
for i=1:max(m,n)
if u(i) == 0
y(i) = 1/dt;
else
y(i) = 0;
end
end

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by