Inverse Fourier Transform?
1 回表示 (過去 30 日間)
古いコメントを表示
The problem: My class was told to write a program which uses the built-in Matlab commands to transform the function
y = 0.25*cos(2*pi*t*f0) + 0.5*sin(2*pi*3*t*f0) - 0.25*cos(2*pi*t*10*f0)
to a frequency function (f0 = 100). We then are supposed to filter out any frequencies above 200 and below 500, take the inverse transform, and plot the resulting graph against the approximation y = 0.5*sin(2*pi*3*t*f0).
My code:
clear;
%Set up the initial conditions
delta_t = 0.000025;
N = 1024;
t = 0:delta_t:N*delta_t;
T_func = 0.25*cos(2*pi*t*100) + 0.5*sin(2*pi*3*t*100) - 0.25*cos(2*pi*t*10*100);
Transform = fft(T_func);
Amp = sqrt(Transform.*conj(Transform));
freq = 0:700/N:700;
figure(1);
subplot(2,1,1);
plot(freq, Amp);
%To cut all the data points below 200, multiply by the point step to find
%the number of points to cut
cut = 200/(700/N);
%Cut out the lower points
Transform(1:cut) = 0;
%Cut out the higher points
Transform(N+1-cut:N+2) = 0;
New_Amp = sqrt(Transform.*conj(Transform));
subplot(2,1,2);
plot(freq, New_Amp);
%Take the inverse and plot it against the approximation
Inv_Trans = ifft(Transform);
Inverse_Amp = sqrt(Inv_Trans.*conj(Inv_Trans));
Approximation = 0.5*sin(2*pi*3*t*100);
figure(2);
plot(t, Approximation, t, Inverse_Amp, 'r');
What's happening: The first transform and filtering are going perfectly, and I come up with these plots: http://tinypic.com/r/2u90th2/6. These look to me to be correct. However, when I take the inverse transform, I come up with this plot: http://tinypic.com/r/25utsa9/6. This looks to be very incorrect. Since I'm using built-in programs, I can't figure out where the error could possibly be. Does anybody have any idea? Thank you!
1 件のコメント
Wayne King
2012 年 4 月 28 日
The frequencies you say you want to remove in your problem statement are not the same you say you remove in your code.
In your code:
%To cut all the data points below 200, multiply by the point step to find
%the number of points to cut
but in your problem statement:
"to filter out any frequencies above 200 and below 500"
which ones do you really want to filter out?
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Frequency Transformations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!