Fourier transform image and a plot of the Fourier coefficients as a function of time.
1 view (last 30 days)
Show older comments
I have create 3 figures; the original image (y), the Fourier transform image (y1), and a plot of the Fourier coefficients as a function of time for cos(2*pi*t) where t=-10:.01:10;
here is my code and my questions:
t=-10:0.1:10;
figure(1)
a=cos(2*pi*t);
a1=repmat(a, 201, 1); %since here we had a as 1x201 and we wanted to create 201x201 we used repmat(a, 201, 1). here 1(rows) times 201 gives 201(rows) but we already had 201 columns so multiplied that by only 1 to get 201.
imshow(a1, []) %this shows the origional 201x201 image I created of cos(2*pi*t). had to create this before taking Ft but why?
a2=fft2(a1); %takes the ft
figure(2)
a3=fftshift(a2); %shows image where the harmonics in the center of the image of the Ft
imshow(a3,[]);
figure(3)
plot(t,abs(a3(101,:))); %this shows the plot of fourier coff
why do I have to use abs of a3 or my fftshift(a2)?
Why do I have to use a3(101,:) again to get a good picture? 

0 Comments
Accepted Answer
Jesus Sanchez
on 28 Nov 2019
Edited: Jesus Sanchez
on 28 Nov 2019
why do I have to use abs of a3 or my fftshift(a2)?
Calculating the absolute value of Fourier coefficients its an easy way to plot them and check their frequency, as they are usually complex numbers. You could also plot the phase, but I guess the point is to check the frequency of your created cosine, which is 2 as expected.
Why do I have to use a3(101,:) again to get a good picture?
The cosine that you created is located at (101,:). Hence, only the plot of that specific row to see the absolute value of the fourier coefficients. You can see this in your figure 2. The two white dots are the created cosine, which are located just in the middle of the figure (line 101).
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!