1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
说明:利用FFT运算实现信号的
一、信号建模 % 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)。 plot(1000*t(1:50),X(1:50)) title(‘Signal Corrupted with Zero-Mean Random Noise’) xlabel(‘t (milliseconds)’) ylabel(‘X(t)’) 二、利用FFT恢复信号 % 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);% 除掉两头的乘2倍 % 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. 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); plot(f,P1) title(‘Single-Sided Amplitude Spectrum of S(t)’) xlabel(‘f (Hz)’) ylabel(‘|P1(f)|’) 获取信号的频率和频率 信号的功率谱信息(周期图求PSD) 功率谱应用与幅度变换之间的关系 具体的步骤是: 信号经过FFT变换,再除N,取左半部分,即1:N/2+1 ; (1)对其进行取取, 然后一点点保持不变,对中间部分乘以2(因为性),即得到的幅频部分; (2)对等进行取吸收,并进行适当的运算,因为再除以中间速率乘法, 然后端几乎保持不变,对以2(对偶性),即得到的谱图速度部分; 对应的频率范围为 f = Fs*(0:(L/2))/L; 即 freq = 0:Fs/length(S):Fs/2; 2.1 对2中对应的功率谱图数值取对数,即为周期图Periodogram求PSD N = length(S); xdft = fft(S); % FFT变换 xdft = xdft(1:N/2+1);% 取右半部分 %% 求幅度 xx = (1/(N)) * abs(xdft);% 右半部分幅度平方除以N的功率,再除以Fs,得到功率谱 xx(2:end-1) = 2*xx(2:end-1); %% 求得PSD 对数值取对数即得到对应的周期图 psdx = (1/(Fs*N)) * abs(xdft).^2;% 右半部分平方除以N的功率,再除以Fs,得到功率谱 psdx(2:end-1) = 2*psdx(2:end-1);% 出去两端,中间部分放大2倍,信号对称 freq = 0:Fs/length(S):Fs/2; % plot(freq,10*log10(psdx)) plot(freq,(psdx)) figure plot(freq,xx) grid on title(‘Periodogram Using FFT’) xlabel(‘Frequency (Hz)’) ylabel(‘Power/Frequency (dB/Hz)’) 重新整理: rng default clear Fs = 1000; t = 0:1/Fs:10-1/Fs; x = 100*cos(2*pi*100*t) ; %% N = length(x); xdft = fft(x); xdft = xdft(1:N/2+1); psdx = (1/(Fs*N)) * abs(xdft).^2; psdx(2:end-1) = 2*psdx(2:end-1); xx = (1/(N)) * abs(xdft); xx(2:end-1) = 2*xx(2:end-1); freq = 0:Fs/length(x):Fs/2; plot(freq,10*log10(psdx)) grid on title(‘Periodogram Using FFT’) xlabel(‘Frequency (Hz)’) ylabel(‘Power/Frequency (dB/Hz)’) figure(2) periodogram(x,rectwin(length(x)),length(x),Fs) figure(3) plot(freq,xx) figure(4) plot(freq,(psdx)) scope = dsp.SpectrumAnalyzer(‘SampleRate’,Fs); scope(x‘) 补充: 数字角频率和模拟频率之间的关系 |
|
|
|
只有小组成员才能发言,加入小组>>
调试STM32H750的FMC总线读写PSRAM遇到的问题求解?
1777 浏览 1 评论
X-NUCLEO-IHM08M1板文档中输出电流为15Arms,15Arms是怎么得出来的呢?
1621 浏览 1 评论
1080 浏览 2 评论
STM32F030F4 HSI时钟温度测试过不去是怎么回事?
728 浏览 2 评论
ST25R3916能否对ISO15693的标签芯片进行分区域写密码?
1678 浏览 2 评论
1937浏览 9评论
STM32仿真器是选择ST-LINK还是选择J-LINK?各有什么优势啊?
731浏览 4评论
STM32F0_TIM2输出pwm2后OLED变暗或者系统重启是怎么回事?
570浏览 3评论
595浏览 3评论
stm32cubemx生成mdk-arm v4项目文件无法打开是什么原因导致的?
554浏览 3评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 01:29 , Processed in 0.738077 second(s), Total 46, Slave 40 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号