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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x

- f* l% ~" J2 \4 j; ~1 U3 }; o目录; S' X$ H6 R& p( J4 J3 U& s

5 V0 S+ J% h, ?  h/ D- DSyntax4 V& `5 w# T, {4 L5 ?) D! P
9 b! {9 |1 X+ E
Description2 z$ o, e( t; O5 D6 j; ]

( q; r4 W8 B$ M5 ]  U       Y = fft(X)+ z+ t. M* h4 O- {/ d3 n/ J' a$ n- r

- o% A; {) J1 [+ Z       Y = fft(X,n)
  O* d9 }, O6 P2 m0 x0 w4 T7 k( ?" c" e
       Y = fft(X,n,dim)
) s. _+ Z0 t6 ]! d1 o  U
8 g0 ]  Q2 D, \8 {Examples9 `" a- Q" W8 Y  L8 l- x7 m

" ]7 B( f$ H$ D% @% c, h6 j       Noisy Signal
+ h7 l; H. e! {" G0 `. [1 m. Z  }3 Q' A0 s+ r5 I

; |# ~& V1 a  ^1 ~$ c5 \

: L  o/ ?1 I. E  n

8 X- }5 W& K& k# k) f. `/ N  {) ?, FSyntax
% e3 ]* d# H% q9 r# a1 j5 l# {( f; H1 r
Y = fft(X)
# `% i0 @# \. L, l
- {, @/ T4 E" S9 Y; v5 m& m; uY = fft(X,n)/ i1 D$ q3 c. s' X: s
+ v9 H+ k8 L' l  @5 x+ s
Y = fft(X,n,dim)
" a( \' T" P$ j) w
+ N( Z* y  p! n# l/ w4 n
: G9 }  G8 _7 s8 e" jDescription
: |+ Q) x" |, R( B& X7 |( i  b

% j: d2 w2 a4 S9 }Y = fft(X)

' z, i7 X- n& s  c+ q( u0 ^: L. \* J; u; v3 }2 Y0 f7 Y
Y = fft(X) 使用fast Fourier transform(FFT)算法计算信号X的离散傅里叶变换:$ r4 `6 `9 }6 X# a9 I
" z( e3 Z) V3 v
  • 如果 X 是一个向量,那么 fft(X) 返回向量的傅里叶变换;
  • 如果 X 是一个矩阵,则 fft(X) 视X的列为向量,然后返回每列的傅里叶变换;
  • 如果X是多维数组,则fft(X)将沿大小不等于1的第一个数组维度的值视为向量,并返回每个向量的傅里叶变换。- u5 A! ?, B% K& v5 L- N

( Q2 p+ m9 }) B# p" P  R

8 z1 w6 f3 q# e) K. K% j6 d& w& S* o
Y = fft(X,n)( j4 _) |( x1 A* R' [

) b& ^# P5 E; b5 B# h# a+ k5 Z% \6 F

% b, z, V. I  H! K3 @+ OY = fft(X,n) 返回 n 点 DFT。 如果未指定任何值,则Y与X的大小相同。& F8 x" @6 I- J, R8 g

( E) P. k1 A- r$ h
  • 如果X是向量并且X的长度小于n,则用尾随零填充X到长度n。
  • 如果X是向量并且X的长度大于n,则X被截断为长度n。
  • 如果X是矩阵,那么每个列都被视为向量情况。
  • 如果X是多维数组,则大小不等于1的第一个数组维度将被视为向量的情况。- F2 K* }, C/ t5 V" E- w

% L' ?, D0 J: R6 z
6 [) ~8 D/ `9 h  i- i: f

, l. r& d& o/ W7 s. P" b( iY = fft(X,n,dim)

, [+ F6 C+ l6 V+ q& P- u2 S1 }
/ X/ ~5 Z: X) I) W7 J$ aY = fft(X,n,dim)沿维度dim返回傅立叶变换。 例如,如果X是矩阵,则fft(X,n,2)返回每行的n点傅立叶变换。
9 o0 e5 F" y1 F1 A1 S
8 U0 e/ X- O: O! R
0 @3 u9 r9 L) C7 H% v+ OExamples

# S7 l! E: @" a, N+ a
$ [" G9 A7 F! i: BNoisy Signal

" {$ J( P: n0 d5 `
6 E: C8 ]- Y+ s使用傅立叶变换来查找隐藏在噪声中的信号的频率分量。
, \! z# G+ T: H1 m* V9 \& q6 D/ m8 |5 c: \
指定采样频率为1 kHz且信号持续时间为1.5秒的信号参数。
" o8 D8 N# G3 z- g$ U8 `
7 W3 y; A3 H" D6 W/ u% [; k! v
  • 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)|')
  • ' S+ P: }& z. N( D; _
            
& H8 I" ~5 k8 T5 @7 v* C/ d5 } * K! o3 g( l" b/ G' J! q( r/ Y
figure(1)是加上零均值的随机噪声后的信号时域图形,通过观察这幅图很难辨别其频率成分。9 m' G9 V3 }9 W0 k! p( G

# D7 X, y4 q, O) K5 S& w. L- u* {5 j

( ~) g! C+ P: o& q1 N
- Q& N; |4 @! }+ Qfigure(2)是X(t)的单边幅度谱,通过这幅图其实已经能够看出信号的频率成分,分别为50Hz和120Hz,其他的频率成分都会噪声的频率分量。
3 m- L* f" F/ N9 {; J3 g, @+ e+ D% l& `( Q( @9 y
) [6 Y( c! H' |

7 ?# _8 Z& Y: t, t, \; kfigure(3)是信号S(t)的单边幅度谱,用作和figure(2)的幅度谱对比,原信号确实只有两个频率成分。. j, H" b2 s8 b  X* x. _1 _9 w

& S- x) ~, }" n7 D4 i7 M
' _/ o* d( ?1 Z% f# t4 l: T
" E' _% }. V; F) ?1 o+ Z' r" C
上面三幅图画到一起:
1 i/ H0 |9 N( v, ]
% t( c: f4 P+ t) l: Y% f

7 Q$ \7 T; ]+ s8 ^" }8 y6 c8 a# N. W  }  p  w5 N. |, a4 ^& V' }
9 c( ^7 l' C  q, H6 }0 D$ W3 K
- d/ D7 @5 J9 y3 L" U; a

1 w! ^" w0 e* p: ~5 Z4 G/ p& q
  • 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-8-4 23:02 , Processed in 0.125000 second(s), 26 queries , Gzip On.

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

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

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