필터 지우기
필터 지우기

How can I plot a comb function?

조회 수: 82 (최근 30일)
Poonam
Poonam 2012년 10월 29일
답변: suketu vaidya 2020년 11월 8일
Hello,
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
Wayne King 2012년 10월 29일
편집: Wayne King 2012년 10월 29일
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.

추가 답변 (4개)

Image Analyst
Image Analyst 2015년 1월 9일
You can use stem() to make a plot that looks like a comb function. See the help.
stem(ones(1,10), 'LineWidth', 2)
ylim([0, 2]);

Pavan Kumar
Pavan Kumar 2013년 8월 1일
Hii Wayne..
I want to plot the comb function but unable to do so..
Could you send me the code for it.
Thanking you

Li
Li 2015년 1월 9일
%Hi, Poonam, maybe you can try this one, too.
clc
clear all
numx = 501;
xmax = 5;
x = linspace(-xmax,xmax,numx);
Delta_X = 0.8;
% sample_x = abs(rem(x,1)); sample = zeros(1,numx);
for j=1:numx
R = abs(rem(x(j)+xmax,Delta_X));
if R == 0;
sample(j) = 1; % the amplitude can be adjusted
end
end
plot(x,sample)
axis tight

suketu vaidya
suketu vaidya 2020년 11월 8일
function taska
h = 1;
x = -pi:0.01:pi;
d = 50;
y0 = -1;
c1=(y0-(d^2/(d^2+1)));
y=@(x)c1*exp(-diff(x))+d*(sin(x)/(d^2+1))+d^2*(cos(x)/d^2+1);
plot(x,y(x));
end
i am not able to plot this graph

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by