当前位置:网站首页>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');
边栏推荐
- Programmer growth Chapter 6: how to choose a company?
- String (Analog
- PLC-Recorder快速监控多个PLC位的技巧
- C#基于当前时间,获取唯一识别号(ID)的方法
- The difference between SQL left join main table restrictions written after on and where
- Order by injection
- 基于Hardhat和Openzeppelin开发可升级合约(一)
- 2022年遭“挤爆”的三款透明LED显示屏
- Wechat applet uses Baidu API to achieve plant recognition
- Bedtools tutorial
猜你喜欢
PKG package manager usage instance in FreeBSD
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
tqdm的多行显示与单行显示
Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
[idea] use the plug-in to reverse generate code with one click
What is the relationship between digital transformation of manufacturing industry and lean production
预言机链上链下调研
RPA进阶(二)Uipath应用实践
Tick Data and Resampling
随机推荐
Thanos Receiver
MySql存储过程游标遍历结果集
ImportError: cannot import name ‘Digraph‘ from ‘graphviz‘
Eight sorting summaries
基于Hardhat编写合约测试用例
Summary of flutter problems
Multi line display and single line display of tqdm
PHP query distance according to longitude and latitude
基于 Openzeppelin 的可升级合约解决方案的注意事项
ros缺少xacro的包
String (Analog
Skills of PLC recorder in quickly monitoring multiple PLC bits
2022年4月17日五心红娘团队收获双份喜报
A white hole formed by antineutrons produced by particle accelerators
【多线程】主线程等待子线程执行完毕在执行并获取执行结果的方式记录(有注解代码无坑)
ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)
【IDEA】使用插件一键逆向生成代码
可昇級合約的原理-DelegateCall
mmrotate旋转目标检测框架使用记录
[cloud native] 2.5 kubernetes core practice (Part 2)