FFT

Good Afternoon All,
I was wondering if matlab's fft function could only be applied to cartesian coordinates? I have generated polar coordinates for the data points and then use a cubic spline for create a function to run the fft on but when i apply the ifft the function seems to have scaled up and shifted. Is this a result of my coordinate system?
Thanks,
Mel

Answers (1)

Walter Roberson
Walter Roberson on 9 Mar 2012

0 votes

fft does not know or care what kind of data it is being applied to.
What are you doing in-between the fft() and the ifft()?
If you fft() some data, change the first element of the result, and fft() back, you will see shifting, as the first element corresponds to the mean of the data (the "base line")

7 Comments

Melissa
Melissa on 9 Mar 2012
%angles and radius are that of almost a perfect circle in polar coordinates of increasing angle
angles= radius=
%Oversampling the data points so the total number of points is Ntheta
Ntheta = 1024;
theta = linspace(-pi,pi,Ntheta);
delta_theta = 2*pi/Ntheta;
%This defines a temporary vector that "wraps around" pi to -pi
theta_temp = -pi:delta_theta:(pi + 5*delta_theta);
%Creating the function to which the fft can be applied
pp = spline(angles,radius);
fft_fun_temp= ppval(pp,theta_temp);
%Overwrite here
fft_fun= zeros(size(theta));
fft_fun(1:Ntheta) = fft_fun_temp(1:Ntheta);
fft_fun(1:6)=fft_fun_temp(Ntheta:Ntheta +5);
fft_coeffs=fft(fft_fun);
%Now I just applied the inverse
fft_inverse=ifft(fft_coeffs)
%Graphed the result of the original which is
rconvert=180./pi;
plot(rconvert.*angles,radius, 'b')
hold on
plot(fft_inverse)
Sean de Wolski
Sean de Wolski on 9 Mar 2012
What is 'angles', 'radius' and any other variables we need to run our code?
Melissa
Melissa on 9 Mar 2012
sorry here is an example of the radius and angle, they didnt copy in but all other lines are there.
radius=[36.9278317597027 36.9295093878675 36.9315457184250 36.9340087089622 36.9369406799480 36.9406056760045 36.9449756161782 36.9503124585876 36.9559684291290 36.9608852002362 36.9641792150386 36.9661569178350 36.9680250503182 36.9703467869017 36.9729256390222 36.9755336806809 36.9777489026147 36.9792999537920 36.9801683642887 36.9802661320884 36.9800480762616 36.9797918020316 36.9798669181455 36.9802569970695 36.9805016377834 36.9797955440264 36.9778463549091 36.9751253049010 36.9726764010568 36.9711740001741 36.9704816151401 36.9701094050457 36.9697088307910 36.9693529735925 36.9688687212724 36.9684000000000 36.9676252157451 36.9666140847558 36.9651196370632 36.9632610388613 36.9606400058457 36.9575944551871 36.9540844801966 36.9505265644927 36.9469102993935 36.9433024935445 36.9395524787163 36.9356208572506 36.9316040426563 36.9276559119676 36.9237500307539 36.9201640363931 36.9170975514486 36.9146998947116 36.9129315538129 36.9118637352161 36.9115010805969 36.9116322568356 36.9121792438045 36.9128954722556 36.9137517963784 36.9147341425136 36.9157129092916 36.9168586746561 36.9179933884881 36.9191975981134 36.9203807404494 36.9215484970182 36.9227590063604 36.9238960586839 36.9250640696928 36.9264000000000
];
angles=[-3.05432553222270 -2.96706004428293 -2.87979476869253 -2.79252657905104 -2.70526162825420 -2.61799540582496 -2.53072779893798 -2.44346162956900 -2.35619550307211 -2.26892936886607 -2.18166317642887 -2.09439787189436 -2.00713284740398 -1.91986423729555 -1.83259875404169 -1.74533266181185 -1.65806604327191 -1.57079965111922 -1.48353323366717 -1.39626680558047 -1.30900032164215 -1.22173272371535 -1.13446730159029 -1.04720059260775 -0.959932487635473 -0.872667549725220 -0.785399176283132 -0.698132532393925 -0.610865834152720 -0.523600031547304 -0.436334520504299 -0.349065439049052 -0.261800025394853 -0.174534045426884 -0.0872678421770528 0 0.0872678421770528 0.174534045426884 0.261800025394853 0.349068903151021 0.436334520504299 0.523601382907698 0.610869598294839 0.698134602784940 0.785401087382606 0.872669620125301 0.959934701569559 1.04720194395287 1.13446730159029 1.22173526343361 1.30900136588717 1.39626760407403 1.48353431063526 1.57080073220030 1.65806712023855 1.74533346030326 1.83259979828254 1.91986770138315 2.00713284740398 2.09439922325066 2.18166472663690 2.26893317651022 2.35619932525988 2.44346543720927 2.53073001285774 2.61799540582496 2.70526162825420 2.79252911875355 2.87979476869253 2.96706004428293 3.05432822463023 3.14159265358979
];
Walter Roberson
Walter Roberson on 9 Mar 2012
What do you get for
max(abs(fft_fun - fft_inverse))
Melissa
Melissa on 9 Mar 2012
ans =
2.8422e-014
Melissa
Melissa on 9 Mar 2012
photo of the plot. http://www.mediafire.com/?1mcyrxgayxoa3al
Walter Roberson
Walter Roberson on 9 Mar 2012
With that small of a difference between those two quantities, the fft / ifft is essentially leaving the data unchanged. If you were to assign
fft_inverse = fft_fun;
that is, to skip the fft and ifft, then you would have essentially no difference in the results.
Looking at your plot, the minimum and maximums of the two are the same, and basically you are just seeing the effect of having supplied explicit x coordinates for the first plot but having used the default 1:length(y) x coordinates for the second plot.
Try replacing your second plot() with
plot(rconvert.*angles, fft_inverse);
I am not positive that that will be correct, but it will give you the common x coordinates to work from for the plots.

Sign in to comment.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Tags

Asked:

on 9 Mar 2012

Community Treasure Hunt

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

Start Hunting!