Fourier transform how to get coefficients

Hey everyone, i know that matlab have the method for fourier transform implemented but i was wondering if there is anything that could give me coefficients of fourier transfrom.

 Réponse acceptée

Star Strider
Star Strider le 15 Déc 2018

0 votes

With the MATLAB fft function, at each frequency, the real value is the cosine coefficient, and the imaginary value is the sine coefficient.
At least that is how I understand it.

12 commentaires

Vincent Sin
Vincent Sin le 15 Déc 2018
i know that too but how to i get them, i want to see the values of the coefficients
As I understand it, those are the coefficient values.
To get the real values for each, use the real and imag functions:
x = your_signal;
X = fft(x)/length(x);
cosine_coefficients = real(X);
sine_coefficients = imag(X);
You need to calculate the frequencies that they apply to. That is not difficult.
Vincent Sin
Vincent Sin le 15 Déc 2018
does this apply also to 2D FFT when im working with pictures ?
Star Strider
Star Strider le 15 Déc 2018
You did not mention anything about a 2D fft before. However, considering that a 2D fft is a Fourier transform of a Fourier transform and across different dimensions, I would say it is. See More About (link) for a brief discussion.
Vincent Sin
Vincent Sin le 15 Déc 2018
Thanks a lot !!!
Star Strider
Star Strider le 15 Déc 2018
As always, my pleasure!
Vincent Sin
Vincent Sin le 15 Déc 2018
is there anyway that we could talk about this problem besides this comment section ?
Star Strider
Star Strider le 15 Déc 2018
I prefer doing everything here. The benefit is that others can see it and comment as well.
Vincent Sin
Vincent Sin le 15 Déc 2018
Modifié(e) : Vincent Sin le 15 Déc 2018
okay so here is the problem i have and i cant find a proper solution to.
We have a school project to do and we decided that we would do it in Matlab
the problem is: We should do a 2D fft of photo, then we have to use only 1/3 of values to draw the picture and we should draw a original photo and next to it the approximation of that photo using fourier basis
I have never done anything like this, we played a bit with fourier transform in school but my knowledge is not enough to solve this type of problem
and our teacher is like if we ask something most likely she would say that we should use internet to find the solution so here i am trying my luck :D
This is now more of an image processing problem than a signal processing problem.
One option is to eliminate the high frequencies, and compare that result with the original:
P = peaks(60);
figure
imagesc(P)
Y = fft2(P);
Ys = fftshift(Y);
P2 = ifft2(ifftshift(Ys(20:40, 20:40)));
figure
imagesc(abs(P2))
Image Analyst probably has some more interesting ideas.
Vincent Sin
Vincent Sin le 15 Déc 2018
And how would you understand that we should use only 1/3 of values to draw that picture?
You can use any subset you like. This is just an example.
Another option might be to take an arbitrary subset of the transformed matrix:
idx = randperm(numel(P), fix(numel(P)/3));
sbs = ind2sub(size(Y), idx);
S = false(size(Y));
S(sbs) = 1;
Ys = Y.*S;
P2 = ifft(Ys);
figure
imagesc(abs(P2))
Try this on the original and the ‘Y’ array after using fftshift.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by