Fourier transform image and a plot of the Fourier coefficients as a function of time.

조회 수: 8 (최근 30일)
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? 1.JPG

채택된 답변

Jesus Sanchez
Jesus Sanchez 2019년 11월 28일
편집: Jesus Sanchez 2019년 11월 28일
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).
  댓글 수: 1
Smit Patel
Smit Patel 2019년 11월 28일
Thank you so much, Jesus! Happy thanksgiving too! Couldn't have been a better save than on today! Your answers make more sense about the code now.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by