当前位置:网站首页>Power Spectral Density Estimates Using FFT---MATLAB
Power Spectral Density Estimates Using FFT---MATLAB
2022-07-02 11:49:00 【Xiaoyu 2022】
% Power Spectral Density Estimates Using FFT
% pr8_2_1
clear all; clc; close all;
randn('state',0); % Random number initialization
Fs = 1000; % sampling frequency
t = 0:1/Fs:1-1/Fs; % Time scale
f1=50; f2=120; % Frequency of two sinusoidal components
x=cos(2*pi*f1*t)+3*cos(2*pi*f2*t)+randn(size(t)); % The signal
% Use FFT
N = length(x); % x length
xdft = fft(x); % FFT
xdft = xdft(1:N/2+1); % Positive frequency
psdx = (1/(Fs*N)) * abs(xdft).^2; % Calculate the power spectral density
psdx(2:end-1) = 2*psdx(2:end-1); % ride 2(2:end-1)
freq = 0:Fs/length(x):Fs/2; % Frequency scale
subplot 211
plot(freq,10*log10(psdx),'k') % Take logarithm to plot
grid on; xlim([0 Fs/2]);
title(' use FFT Periodic graph of ')
xlabel(' frequency /Hz')
ylabel(' Power spectral density /(dB/Hz)')
% call periodogram function
[Pxx,f]=periodogram(x,rectwin(length(x)),N,Fs);
subplot 212
plot(freq,10*log10(Pxx),'k'); % Take logarithm to plot
grid on; xlim([0 Fs/2]);
title(' call periodogram Periodic graph of function ')
xlabel(' frequency /Hz')
ylabel(' Power spectral density /(dB/Hz)')
mxerr = max(psdx'-Pxx) % Find the maximum difference between the two methods
set(gcf,'color','w');
边栏推荐
- How to Create a Nice Box and Whisker Plot in R
- Liftover for genome coordinate conversion
- BEAUTIFUL GGPLOT VENN DIAGRAM WITH R
- 原生方法合并word
- How to Add P-Values onto Horizontal GGPLOTS
- HOW TO ADD P-VALUES ONTO A GROUPED GGPLOT USING THE GGPUBR R PACKAGE
- Always report errors when connecting to MySQL database
- 通讯录的实现(文件版本)
- Some things configured from ros1 to ros2
- 行業的分析
猜你喜欢
Develop scalable contracts based on hardhat and openzeppelin (II)
How to Create a Nice Box and Whisker Plot in R
BEAUTIFUL GGPLOT VENN DIAGRAM WITH R
多文件程序X32dbg动态调试
Amazon cloud technology community builder application window opens
Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'
Power Spectral Density Estimates Using FFT---MATLAB
GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation
由粒子加速器产生的反中子形成的白洞
随机推荐
What week is a date obtained by QT
Some problems encountered in introducing lvgl into esp32 Arduino
Installation of ROS gazebo related packages
可升级合约的原理-DelegateCall
时间格式化显示
HOW TO ADD P-VALUES TO GGPLOT FACETS
在连接mysql数据库的时候一直报错
liftOver进行基因组坐标转换
Homer forecast motif
Tdsql | difficult employment? Tencent cloud database micro authentication to help you
Develop scalable contracts based on hardhat and openzeppelin (I)
Visualization of chip SEQ data by deeptools
2022年4月17日五心红娘团队收获双份喜报
Some things configured from ros1 to ros2
GGPlot Examples Best Reference
Principe du contrat évolutif - delegatecall
Esp32 stores the distribution network information +led displays the distribution network status + press the key to clear the distribution network information (source code attached)
微信小程序利用百度api达成植物识别
bedtools使用教程
Principle of scalable contract delegatecall