How to draw the delta signal in matlab
    55 views (last 30 days)
  
       Show older comments
    
I was trying to  draw  but I wasn't able to
but I wasn't able to 
 but I wasn't able to
but I wasn't able to 0 Comments
Answers (3)
  the cyclist
      
      
 on 27 Mar 2023
        
      Edited: the cyclist
      
      
 on 27 Mar 2023
  
      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).
  Star Strider
      
      
 on 28 Mar 2023
        The  function normally will not plot in MATLAB because it has infinite amplitude and infinitesimal width.
 function normally will not plot in MATLAB because it has infinite amplitude and infinitesimal width.  
 function normally will not plot in MATLAB because it has infinite amplitude and infinitesimal width.
 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)
idx = Delta == Inf;
Delta(idx) = 1;
figure
stem(t, Delta, 'filled')
axis('padded')
.
0 Comments
  Carlos M. Velez S.
 on 24 Jul 2025
        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
0 Comments
See Also
Categories
				Find more on Multirate Signal Processing in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



