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

边栏推荐
- Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
- 由粒子加速器产生的反中子形成的白洞
- Pyqt5+opencv project practice: microcirculator pictures, video recording and manual comparison software (with source code)
- Webauthn - official development document
- STM32 single chip microcomputer programming learning
- Wechat applet uses Baidu API to achieve plant recognition
- Tiktok overseas tiktok: finalizing the final data security agreement with Biden government
- How to Create a Beautiful Plots in R with Summary Statistics Labels
- [visual studio 2019] create and import cmake project
- Is the stock account given by qiniu business school safe? Can I open an account?
猜你喜欢

在连接mysql数据库的时候一直报错

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

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

How to Create a Nice Box and Whisker Plot in R

Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting

Always report errors when connecting to MySQL database

R HISTOGRAM EXAMPLE QUICK REFERENCE

Esp32 stores the distribution network information +led displays the distribution network status + press the key to clear the distribution network information (source code attached)

Basic usage of MySQL in centos8

Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
随机推荐
File operation (detailed!)
Three transparent LED displays that were "crowded" in 2022
C # method of obtaining a unique identification number (ID) based on the current time
念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
【多线程】主线程等待子线程执行完毕在执行并获取执行结果的方式记录(有注解代码无坑)
php 二维、多维 数组打乱顺序,PHP_php打乱数组二维数组多维数组的简单实例,php中的shuffle函数只能打乱一维
pgsql 字符串转数组关联其他表,匹配 拼接后原顺序展示
6. Introduce you to LED soft film screen. LED soft film screen size | price | installation | application
接口调试工具概论
动态内存(进阶四)
PX4 Position_ Control RC_ Remoter import
HOW TO CREATE AN INTERACTIVE CORRELATION MATRIX HEATMAP IN R
Develop scalable contracts based on hardhat and openzeppelin (I)
Some suggestions for young people who are about to enter the workplace in the graduation season
Programmer growth Chapter 6: how to choose a company?
Is it safe to open a stock account online? I'm a novice, please guide me
A sharp tool for exposing data inconsistencies -- a real-time verification system
How to Visualize Missing Data in R using a Heatmap
QT meter custom control
[visual studio 2019] create MFC desktop program (install MFC development components | create MFC application | edit MFC application window | add click event for button | Modify button text | open appl