代码
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,3205,3210,3204,3205,3198,3199,3191,3194,3186,3187,3177,3176,3165,3166,3156,3156,3148,3150,3139,3142,3134,3134,3127,3128,3123,3126,3121,3125,3121,3129,3128,3144,3154,3178,3188,3212,3232,3260,3281,3308,3326,3352,3361,3377,3381,3389,3383,3384,3372,3368,3361,3364,3353,3349,3334,3328,3308,3298,3280,3274,3259,3253,3243,3238,3230,3232,3225,3230,3225,3231,3225,3229,3220,3224,3216,3218,3209,3208,3197,3197,3189,3188,3175,3176,3163,3164,3152,3152,3140,3141,3131,3132,3124,3126,3119,3120,3113,3118,3111,3118,3112,3120,3121,3138,3150,3175,3188,3215,3235,3268,3291,3323,3342,3370,3381,3399,3401,3409,3403,3406,3394,3389,3385,3390,3382,3380,3363,3356,3337,3325,3302,3293,3272,3264,3248,3244,3230,3229,3219,3220,3210,3214,3204,3207,3198,3197,3187,3186,3175,3175,3164,3162,3150,3149,3136,3134,3125,3122,3110,3110,3101,3101,3093,3095,3086,3088,3080,3083,3076,3080,3071,3075,3069,3077,3075,3089,3096,3117,3133,3157,3175,3210,3234,3271,3298,3333,3353,3380,3392,3409,3412,3421,3413,3412,3402,3396,3394,3397,3385,3381,3364,3354,3331,3320,3298,3287,3270,3263,3246,3241,3229,3227,3216,3219,3208,3211,3202,3204,3195,3196,3187,3186,3176,3174,3162,3161,3149,3148,3137,3136,3123,3122,3110,3109,3099,3099,3089,3090,3081,3082,3078,3080,3074,3078,3073,3078,3075,3081,3084,3097,3108,3134,3147,3177,3198,3231,3257,3294,3315,3346,3362,3381,3388,3398,3394];
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, 'r', 'linewidth', 4)
plot( real( ifft_result ) , 'b', 'linewidth', 4 )legend({'原始数据', '去噪后'})
结果