DIRAC(X) is zero for all X, except X == 0 where it is infinite.
     DIRAC(X) is not a function in the strict sense, but rather a distribution with
     int(dirac(x-a)*f(x),-inf,inf) = f(a) and diff(heaviside(x),x) = dirac(x).

Dirac.m
function Y = dirac(X)
Y = zeros(size(X));
Y(X == 0) = Inf;

< Approximate Dirac delta Function >
사용자 삽입 이미지< Matabl Promgram Source >

<BR>t=[-5:0.001:5]; &nbsp;&nbsp; % 시구간을 -5부터 5까지로 지정<BR>a=[0.01;0.1;0.5]; % a 값을 0.01, 0.1, 0.5로 지정<BR><BR>for i=1:3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; % 세 경우 연산을 동시에 수행, 계산 결과는 각 열에 저장<BR>g(i,:)=1/(sqrt(2*pi)*a(i))*exp(-t.^2/(2*a(i).^2));<BR>c(i,:)=2*a(i)./(a(i)^2+4*pi^2*t.^2);<BR>end<BR>area_g=sum(g,2)*0.001; % area Gauss % 각 열에 대해서 덧셈연산을 수행<BR>area_c=sum(c,2)*0.001; % area Cauchy %&nbsp; 각 열에 대해서 덧셈연산을 수행<BR><BR>figure(1) % Gauss 에 대한 Figure 생성<BR>plot(t,g); % 그래프 작성 및 설정<BR>title('g(t)=1/(sqrt(2pi)a)*exp(-t^2/2a^2), a&gt;0')<BR>legend('a=0.01','a=0.1','a=0.5')<BR>text(2.0,30,sprintf('a=0.01 area: %.4f',area_g(1)))<BR>text(2.0,28.5,sprintf('a=0.1 area: %.4f',area_g(2)))<BR>text(2.0,27,sprintf('a=0.5 area: %.4f',area_g(3)))<BR><BR>figure(2)<BR>plot(t,c);<BR>title('c(t)=2a/(a^2+4pi^2t^2), a&gt;0')<BR>legend('a=0.01','a=0.1','a=0.5')<BR>text(2.0,150,sprintf('a=0.01 area: %.4f',area_c(1)))<BR>text(2.0,140,sprintf('a=0.1 area: %.4f',area_c(2)))<BR>text(2.0,130,sprintf('a=0.5 area: %.4f',area_c(3)))<BR>


< Figure >