How can I plot a comb function?
202 views (last 30 days)
A comb function is an array of delta functions spaced equally. I want to plot a function like this. F(x)= comb(2x)*sinc(50x).sinc^2(x). I could manage the sinc and the sinc^2. But I don't understand how I can plot the comb function which is a summation of deltas from -inf to +inf
Wayne King on 29 Oct 2012
Edited: Wayne King on 29 Oct 2012
You can simply create a discrete-time (Kronecker delta) impulse and repeat that. For example:
x = 0:(2*pi)/1000:pi-(2*pi)/1000;
diraccomb = zeros(size(x));
diraccomb(1) = 1;
diraccomb = repmat(diraccomb,1,10);
xnew = 0:(2*pi)/1000:(5000*(2*pi)/1000)-(2*pi)/1000;
The above is a Dirac comb spaced at pi. You can easily modify for any sampling grid or period.
More Answers (4)
Image Analyst on 9 Jan 2015
You can use stem() to make a plot that looks like a comb function. See the help.
stem(ones(1,10), 'LineWidth', 2)
Pavan Kumar on 1 Aug 2013
I want to plot the comb function but unable to do so..
Could you send me the code for it.
Li on 9 Jan 2015
%Hi, Poonam, maybe you can try this one, too.
numx = 501;
xmax = 5;
x = linspace(-xmax,xmax,numx);
Delta_X = 0.8;
% sample_x = abs(rem(x,1)); sample = zeros(1,numx);
R = abs(rem(x(j)+xmax,Delta_X));
if R == 0;
sample(j) = 1; % the amplitude can be adjusted
suketu vaidya on 8 Nov 2020
h = 1;
x = -pi:0.01:pi;
d = 50;
y0 = -1;
i am not able to plot this graph