Using MATLAB to get the fourier transform of dirac delta function

Click For Summary

Discussion Overview

The discussion revolves around using MATLAB to compute the Fourier transform of the Dirac delta function and a cosine function. Participants explore issues related to the effects of changing the time duration on the resulting Fourier transform outputs.

Discussion Character

  • Homework-related
  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes their MATLAB code for calculating the Fourier transform of the Dirac delta function and questions why the output changes when the time duration is altered.
  • Another participant suggests that the confusion may stem from the relationship between the sampling rate and the length of the time vector, indicating that dividing by the length is effectively multiplying by the sampling rate.
  • A participant notes that a similar approach does not yield consistent results when applied to a cosine function, expressing confusion over the amplitude changes when the time setting is modified.
  • Further discussion reveals that some participants have encountered similar issues and are uncertain about the underlying reasons, mentioning that this topic is covered in Digital Signal Processing literature.
  • One participant seeks recommendations for books or sections that discuss these concepts, particularly in relation to the sampling theorem and Fourier integrals.

Areas of Agreement / Disagreement

Participants express uncertainty regarding the effects of changing the time duration on the Fourier transform outputs, with no consensus on the reasons behind the observed behavior.

Contextual Notes

Participants acknowledge limitations in their understanding of the relationship between sampling rate, time duration, and Fourier transform results, indicating a dependence on definitions and unresolved mathematical steps.

luckycool
Messages
3
Reaction score
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.
 
Physics news on Phys.org
That part's tricky and it took me a looong time to figure it out.
What they're pretty much doing in the examples where you see them divide by L is that they're actually multiplying by the sampling rate dt. It's just that in those examples where they divide by L the time ends at 1s so 1s/length(t) = dt.
 
Last edited:
Thanks so much.

However, if I using this way for cosine function, then it doesn't work again.
u2=1*cos(20*t);
U2=fftshift(fft(u2))*dt;

This time, when I change the time setting, the value of U2 will change.

It's so strange.
 
You mean when you change the end time the value given changes from 0.5 to something else?

Sorry I had that problem too and I don't understand why...

I haven't been able to find an answer to this either, but I know they discuss this topic in Digital Signal Processing classes/books.
 
Hi, thanks again :)

If I change from t(end)=2 to other value then U2(f) will change its amplitude if I use dt instead of length(t).
But it's ok, I will check it with books. Do you know in which book or which section they discuss this topic?
 
Nope sorry, I haven't taken that class yet.
But I think it should be discussed in the same section as the sampling theorem or maybe the Fourier integrals.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 31 ·
2
Replies
31
Views
5K
Replies
4
Views
2K
  • · Replies 25 ·
Replies
25
Views
4K
  • · Replies 2 ·
Replies
2
Views
1K