Reputation: 14189
I'm trying to plot the Dirac delta function in Matlab using plot
, but I don't see anything in the graph. How do I visualize it?
Upvotes: 1
Views: 35553
Reputation: 158
I personally prefer using dirac
and setting Inf
to 1
or another amplitude.
x = -1:0.1:1;
y = dirac(x);
idx = y == Inf; % find Inf
y(idx) = 1; % set Inf to some amplitude
stem(x,y)
Of course, the other answer is perfectly valid. This is just personal preference for being explicit.
Upvotes: 1