%傅里叶变换去噪
close all
data = [3132,3133,3125,3128,3121,3123,3121,3125,3116,3120,3115,3121,3121,3129,3134,3150,3164,3186,3197,3221,3238,3265,3281,3306,3319,3336,3339,3351,3352,3357,3349,3350,3339,3346,3340,3342,3328,3324,3308,3300,3284,3275,3259,3254,3241,3237,3227,3226,3216,3218,3211,3213,3209,3210,];
original_data = data;
data( 20 ) = 1000;
% figure, plot( data )
fft_result = fft( data );
% 要截断的点个数,这个数越大,越接近原始数据,越小,越平滑
cutoff_number = 10;
m = length( data );
fft_result( cutoff_number:m-cutoff_number-1 ) = 0;
ifft_result = ifft( fft_result );
figure
hold on
plot( original_data, ‘b’, ‘linewidth’, 4)
plot( real( ifft_result ) , ‘g’, ‘linewidth’, 4 )
legend({‘原始数据’, ‘去噪后’})