当前位置:网站首页>Power Spectral Density Estimates Using FFT---MATLAB
Power Spectral Density Estimates Using FFT---MATLAB
2022-07-02 09:41:00 【小宇2022】
% Power Spectral Density Estimates Using FFT
% pr8_2_1
clear all; clc; close all;
randn('state',0); % 随机数初始化
Fs = 1000; % 采样频率
t = 0:1/Fs:1-1/Fs; % 时间刻度
f1=50; f2=120; % 两个正弦分量频率
x=cos(2*pi*f1*t)+3*cos(2*pi*f2*t)+randn(size(t)); % 信号
% 使用FFT
N = length(x); % x长度
xdft = fft(x); % FFT
xdft = xdft(1:N/2+1); % 取正频率
psdx = (1/(Fs*N)) * abs(xdft).^2; % 计算功率谱密度
psdx(2:end-1) = 2*psdx(2:end-1); % 乘2(2:end-1)
freq = 0:Fs/length(x):Fs/2; % 频率刻度
subplot 211
plot(freq,10*log10(psdx),'k') % 取对数作图
grid on; xlim([0 Fs/2]);
title('用FFT的周期图')
xlabel('频率/Hz')
ylabel('功率谱密度/(dB/Hz)')
% 调用periodogram函数
[Pxx,f]=periodogram(x,rectwin(length(x)),N,Fs);
subplot 212
plot(freq,10*log10(Pxx),'k'); % 取对数作图
grid on; xlim([0 Fs/2]);
title('调用periodogram函数的周期图')
xlabel('频率/Hz')
ylabel('功率谱密度/(dB/Hz)')
mxerr = max(psdx'-Pxx) % 求两种方法的最大差值
set(gcf,'color','w');

边栏推荐
- Basic usage of MySQL in centos8
- php 根据经纬度查询距离
- How to Create a Beautiful Plots in R with Summary Statistics Labels
- Mmrotate rotation target detection framework usage record
- RPA进阶(二)Uipath应用实践
- PX4 Position_Control RC_Remoter引入
- Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
- [idea] use the plug-in to reverse generate code with one click
- SSRF
- Tick Data and Resampling
猜你喜欢

GGPUBR: HOW TO ADD ADJUSTED P-VALUES TO A MULTI-PANEL GGPLOT

可升级合约的原理-DelegateCall

由粒子加速器产生的反中子形成的白洞

ESP32音频框架 ESP-ADF 添加按键外设流程代码跟踪

Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic

map集合赋值到数据库

ctf 记录

电脑无缘无故黑屏,无法调节亮度。

Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting

6方面带你认识LED软膜屏 LED软膜屏尺寸|价格|安装|应用
随机推荐
QT获取某个日期是第几周
微信小程序利用百度api达成植物识别
[cloud native] 2.5 kubernetes core practice (Part 2)
【云原生】2.5 Kubernetes 核心实战(下)
Introduction to interface debugging tools
ros缺少xacro的包
The working day of the month is calculated from the 1st day of each month
C # method of obtaining a unique identification number (ID) based on the current time
Summary of flutter problems
Functional interfaces and method references
R HISTOGRAM EXAMPLE QUICK REFERENCE
Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
flutter 问题总结
接口调试工具概论
Tiktok overseas tiktok: finalizing the final data security agreement with Biden government
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
原生方法合并word
基于Hardhat编写合约测试用例
II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation
Some suggestions for young people who are about to enter the workplace in the graduation season