当前位置:网站首页>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');

边栏推荐
猜你喜欢

excel表格中选中单元格出现十字带阴影的选中效果

MySQL linked list data storage query sorting problem

PYQT5+openCV项目实战:微循环仪图片、视频记录和人工对比软件(附源码)

Jinshanyun - 2023 Summer Internship

Develop scalable contracts based on hardhat and openzeppelin (II)

Seriation in R: How to Optimally Order Objects in a Data Matrice

【IDEA】使用插件一键逆向生成代码

VS2019代码中包含中文内容导致的编译错误和打印输出乱码问题

How to Visualize Missing Data in R using a Heatmap

Internship report skywalking distributed link tracking?
随机推荐
Is it safe to open a stock account through the QR code of the securities manager? Or is it safe to open an account in a securities company?
bedtools使用教程
The difference between SQL left join main table restrictions written after on and where
The working day of the month is calculated from the 1st day of each month
Webauthn - official development document
6方面带你认识LED软膜屏 LED软膜屏尺寸|价格|安装|应用
接口调试工具概论
数字化转型挂帅复产复工,线上线下全融合重建商业逻辑
Amazon cloud technology community builder application window opens
SQLite modify column type
念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
A white hole formed by antineutrons produced by particle accelerators
mmrotate旋转目标检测框架使用记录
Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'
JS -- take a number randomly from the array every call, and it cannot be the same as the last time
A sharp tool for exposing data inconsistencies -- a real-time verification system
Summary of data export methods in powerbi
从攻击面视角,看信创零信任方案实践
excel表格中选中单元格出现十字带阴影的选中效果
R HISTOGRAM EXAMPLE QUICK REFERENCE