- #1

- 3

- 0

## Homework Statement

Dear all,

I have a problem when I using MATLAB to get the fourier transform of dirac delta function. below is my code.

## Homework Equations

clear all;

clc;

close all;

% t=0:0.002:2;

t=0:0.002:4;

dt=t(2)-t(1);

u=zeros(size(t));

pos0=find(t>=1,1);

u(pos0)=1/dt;

f=linspace(-.5/dt,.5/dt,length(t));

U=fftshift(fft(u))/length(t);

figure;subplot(2,1,1);hold on;plot(t,u);

subplot(2,1,2);hold on;plot(f,abs(U));

## The Attempt at a Solution

I have a doubt that why when I change the end of time to 4, the absolute value of U(f) would be the half when I set the time as 2?

Thank you very much.