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

边栏推荐
- [multithreading] the main thread waits for the sub thread to finish executing, and records the way to execute and obtain the execution result (with annotated code and no pit)
- C#基于当前时间,获取唯一识别号(ID)的方法
- PHP query distance according to longitude and latitude
- Pyqt5+opencv project practice: microcirculator pictures, video recording and manual comparison software (with source code)
- ESP32音频框架 ESP-ADF 添加按键外设流程代码跟踪
- 基于 Openzeppelin 的可升级合约解决方案的注意事项
- 行業的分析
- Bedtools tutorial
- ESP32存储配网信息+LED显示配网状态+按键清除配网信息(附源码)
- Skills of PLC recorder in quickly monitoring multiple PLC bits
猜你喜欢

抖音海外版TikTok:正与拜登政府敲定最终数据安全协议

2022年遭“挤爆”的三款透明LED显示屏

GGPlot Examples Best Reference

BEAUTIFUL GGPLOT VENN DIAGRAM WITH R

Redis exceeds the maximum memory error oom command not allowed when used memory & gt; ' maxmemory'

多文件程序X32dbg动态调试

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

How to Create a Beautiful Plots in R with Summary Statistics Labels

Tdsql | difficult employment? Tencent cloud database micro authentication to help you

The selected cells in Excel form have the selection effect of cross shading
随机推荐
抖音海外版TikTok:正与拜登政府敲定最终数据安全协议
【2022 ACTF-wp】
GGPlot Examples Best Reference
Introduction to interface debugging tools
通讯录的实现(文件版本)
Summary of flutter problems
mysql链表数据存储查询排序问题
ROS lacks xacro package
原生方法合并word
Seriation in R: How to Optimally Order Objects in a Data Matrice
File operation (detailed!)
PHP 2D and multidimensional arrays are out of order, PHP_ PHP scrambles a simple example of a two-dimensional array and a multi-dimensional array. The shuffle function in PHP can only scramble one-dim
A white hole formed by antineutrons produced by particle accelerators
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
MySQL stored procedure cursor traversal result set
PgSQL string is converted to array and associated with other tables, which are displayed in the original order after matching and splicing
C # method of obtaining a unique identification number (ID) based on the current time
YYGH-10-微信支付
PLC-Recorder快速监控多个PLC位的技巧
Eight sorting summaries