找回密码
 注册
关于网站域名变更的通知
查看: 597|回复: 2
打印 上一主题 下一主题

MATLAB —— 信号处理工具箱之fft的介绍和相关案例分析

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-11-20 10:16 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
) d7 U4 K9 s1 A& [
目录
6 }& m& r) j! Y4 b0 R0 q  V
  j% S2 Z* i6 K: w! H' z1 c$ |Syntax. p  k# N" U, t3 w

2 x5 V6 @6 m, g% o* ]: [Description3 O& z% X; H0 a3 B; \! D
! q5 n5 J9 x! @% k9 r
       Y = fft(X)
# @( ]) f' r9 a% e0 b
+ d) s- _  O+ n% g% ~8 [       Y = fft(X,n)
; C) O- m, Z( F  E4 Z' X1 G
5 ~" r/ @; Y+ m/ |2 J       Y = fft(X,n,dim)
# Y( e5 J* d+ U0 G0 v4 ?+ p6 X  d: p% T' Y* v+ ~
Examples
7 j# J! r8 o+ B5 v$ e6 p8 t0 H: r2 K- q, H' Z4 F) f: Q1 g
       Noisy Signal. J  d/ H$ }% o: d2 A0 r
% U  N% f: q$ i( ?

7 _0 s# k+ V. k, e
7 w" q- D; V6 N% K

: B5 P  k. J% `6 |! }6 C7 ]; }6 ASyntax7 G9 _8 g6 ?" d8 E1 ~0 G) s
  j  G1 p6 M5 X, B) U# x
Y = fft(X)
3 _9 Y. j' }9 o8 N! |7 q. d4 l# x
+ J1 a# u! ~4 h1 ~: Y' uY = fft(X,n)
  g# P0 K: a* k/ x
* P! n" v' r5 K+ k8 x' uY = fft(X,n,dim)
1 O7 V3 c( M* `+ x% D  I! p  X# S# N4 z! H

( h% z, D9 p9 s7 s$ Z4 |Description
" \$ z5 F1 d7 H* a9 U7 j4 @) ]
9 o2 w7 V; R6 o% x0 r) R( r
Y = fft(X)

" }$ N( z4 z8 B; Q
) ~4 p1 F) D$ ^& p+ N7 {Y = fft(X) 使用fast Fourier transform(FFT)算法计算信号X的离散傅里叶变换:8 c! S% A0 d+ @5 A* G" L
& k6 R2 ?2 w, m! ~& `. n
  • 如果 X 是一个向量,那么 fft(X) 返回向量的傅里叶变换;
  • 如果 X 是一个矩阵,则 fft(X) 视X的列为向量,然后返回每列的傅里叶变换;
  • 如果X是多维数组,则fft(X)将沿大小不等于1的第一个数组维度的值视为向量,并返回每个向量的傅里叶变换。% H: N. z- r7 O) K( `

0 f; a$ i0 b& j5 r0 a6 D& d) p
8 Y2 L6 m* x2 x0 _$ r+ L6 W% n

$ G6 k3 p0 ?, b4 _# M& sY = fft(X,n)* B* b: P8 ^; Y5 r

3 I8 J8 D; e  Z# P. [
/ d% A6 E# |4 X: \- [, F
Y = fft(X,n) 返回 n 点 DFT。 如果未指定任何值,则Y与X的大小相同。
) f! m% S/ o. Z3 T; l' |/ n" x1 C6 X$ a; R" W
  • 如果X是向量并且X的长度小于n,则用尾随零填充X到长度n。
  • 如果X是向量并且X的长度大于n,则X被截断为长度n。
  • 如果X是矩阵,那么每个列都被视为向量情况。
  • 如果X是多维数组,则大小不等于1的第一个数组维度将被视为向量的情况。
    & e$ p! b- ]3 B4 w0 @( G  u7 u
% r+ d- }# b( c- j5 P# e( b6 C4 p) \
1 d2 u' o6 W1 t6 }; m( |# Q
+ b4 X" @. W: t: G9 @# ^$ A! e$ d
Y = fft(X,n,dim)

4 {1 ]5 p, R3 z: W6 A
& W' ^& I& g+ K3 ?  RY = fft(X,n,dim)沿维度dim返回傅立叶变换。 例如,如果X是矩阵,则fft(X,n,2)返回每行的n点傅立叶变换。
. O" l. U. \/ L/ b. l* w
8 H! @$ _* Q" x- L' ~% @+ }7 o# D+ \0 f( b# e3 w
Examples
1 W" d: z8 a/ ^1 s7 A( ~

. ]' N6 V& D0 r# f& XNoisy Signal
8 G  g6 m7 |9 U2 g; r2 L7 s
- a, o$ D- H/ k5 N' T" B2 _1 D* d
使用傅立叶变换来查找隐藏在噪声中的信号的频率分量。9 s0 G2 G+ ?; K0 q- u5 {, l, V
8 e/ h4 e4 y: e) \6 k1 S
指定采样频率为1 kHz且信号持续时间为1.5秒的信号参数。, U6 K$ _0 a% ^& s( z

; \5 y& P7 a) x( r
  • clc
  • clear
  • close all
  • % Use Fourier transforms to find the frequency components of a signal buried in noise.
  • % Specify the parameters of a signal with a sampling frequency of 1 kHz and a signal duration of 1.5 seconds.
  • Fs = 1000;            % Sampling frequency
  • T = 1/Fs;             % Sampling period
  • L = 1500;             % Length of signal
  • t = (0:L-1)*T;        % Time vector
  • % Form a signal containing a 50 Hz sinusoid of amplitude 0.7 and a 120 Hz sinusoid of amplitude 1.
  • S = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
  • % Corrupt the signal with zero-mean white noise with a variance of 4.
  • X = S + 2*randn(size(t));
  • % Plot the noisy signal in the time domain. It is difficult to identify the frequency components by looking at the signal X(t).
  • figure();
  • plot(1000*t(1:50),X(1:50))
  • title('Signal Corrupted with Zero-Mean Random Noise')
  • xlabel('t (milliseconds)')
  • ylabel('X(t)')
  • % Compute the Fourier transform of the signal.
  • Y = fft(X);
  • % Compute the two-sided spectrum P2. Then compute the single-sided spectrum P1 based on P2 and the even-valued signal length L.
  • P2 = abs(Y/L);
  • P1 = P2(1:L/2+1);
  • P1(2:end-1) = 2*P1(2:end-1);
  • % Define the frequency domain f and plot the single-sided amplitude spectrum P1.
  • % The amplitudes are not exactly at 0.7 and 1, as expected, because of the added noise. On average,
  • % longer signals produce better frequency approximations.
  • figure();
  • f = Fs*(0:(L/2))/L;
  • plot(f,P1)
  • title('Single-Sided Amplitude Spectrum of X(t)')
  • xlabel('f (Hz)')
  • ylabel('|P1(f)|')
  • % Now, take the Fourier transform of the original, uncorrupted signal and retrieve the exact amplitudes, 0.7 and 1.0.
  • %
  • Y = fft(S);
  • P2 = abs(Y/L);
  • P1 = P2(1:L/2+1);
  • P1(2:end-1) = 2*P1(2:end-1);
  • figure();
  • plot(f,P1)
  • title('Single-Sided Amplitude Spectrum of S(t)')
  • xlabel('f (Hz)')
  • ylabel('|P1(f)|')

  • ! U1 E& f1 Q$ W) d
            
2 }6 i) P6 s% [! h/ K9 O% m& i! D $ D" \( A0 W  h( E
figure(1)是加上零均值的随机噪声后的信号时域图形,通过观察这幅图很难辨别其频率成分。
0 h! U( a2 ]# n' t7 i& A
+ i5 W. G# Q5 ]4 O% V

5 T& X/ q" m9 l, c8 g7 `3 p
4 v3 G) Y) r' G7 ?- d( A9 U7 afigure(2)是X(t)的单边幅度谱,通过这幅图其实已经能够看出信号的频率成分,分别为50Hz和120Hz,其他的频率成分都会噪声的频率分量。$ b7 x& g+ [+ y7 P3 E8 B

1 ]/ h& d. V2 }( I; ~; p/ p3 l! Y
/ L* A6 H6 H8 X- z) U/ Q+ v/ u+ T) r

0 f; ^) u- X, M* [7 }' zfigure(3)是信号S(t)的单边幅度谱,用作和figure(2)的幅度谱对比,原信号确实只有两个频率成分。
3 e4 R' e+ e9 Q6 v1 d  E5 n- t% S4 k8 n0 l- K8 T
7 I& A$ B+ f$ O

( p$ B4 G3 B" y2 f上面三幅图画到一起:* |& ?7 T. v; C0 z6 M2 s

6 o: A) R! W+ Z- Y; f3 Y% e
* F: Q6 X; w* l; K
* V, n" Y, L1 M6 u- T3 ]

& Y& t9 K  U+ F2 v. s  Q
! l0 V4 o4 M! p3 z) \( j
5 V) d- T6 m7 U2 l/ h
  • TA的每日心情
    开心
    2020-1-17 15:01
  • 签到天数: 38 天

    [LV.5]常住居民I

    2#
    发表于 2019-11-21 15:55 | 只看该作者
    在信号处理领用  matlab  仿真用的多吧。。。。
  • TA的每日心情
    开心
    2020-12-3 15:53
  • 签到天数: 38 天

    [LV.5]常住居民I

    3#
    发表于 2019-11-26 18:03 | 只看该作者
    看看 ,学习一下
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    关闭

    推荐内容上一条 /1 下一条

    EDA365公众号

    关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

    GMT+8, 2025-11-24 00:37 , Processed in 0.171875 second(s), 26 queries , Gzip On.

    深圳市墨知创新科技有限公司

    地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

    快速回复 返回顶部 返回列表