Frequency domain response from time domain response using PSD

10 次查看(过去 30 天)
Hii all,
I used FFT in Matlab to convert time domain wave elevation to frequency domain JONSWAP spectrum. But the spectrum is supposed to be in smooth curve but I am getting unwanted peaks and noise. Please help me to get the spectrum smooth. I am attaching the matlab script below and the spectrum obtained and what I am supposed to get.
clear;
clc;
Wave1= xlsread('WaveElev_Time_LC1.xlsx');
Wave=Wave1(:,2);
figure();
plot(Wave1(:,1),Wave);
title("Wave elevation in Time Domain");
xlabel('Time(s)','linewidth',3);
ylabel('Wave Elevation(m)','linewidth',3);
xlim([0 3600]);
Ns=length(Wave);
fs=1/0.0125;
fft_Wave=fft(Wave);
fft_Wave = fft_Wave(1:Ns/2+1);
psdx = (1/(fs*Ns)) * abs(fft_Wave).^2;
psdx(2:end-1) = 2*psdx(2:end-1);
freq = 0:fs/Ns:fs/2;
y = smooth(freq, psdx);
figure();
plot(freq,y,'linewidth',2);
xlim([0 0.2])
  1 个评论
Mathieu NOE
Mathieu NOE 2022-3-1
hello
try with smoothdata , I would suggest with gaussian window
adapt the window length to get the desired amount of smootihing

请先登录,再进行评论。

回答(1 个)

Balavignesh
Balavignesh 2024-1-11
Hi Mohammed,
As per my understanding, you are encountering spectral leakage and noise in your Fast Fourier Transform (FFT) output, which is common when dealing with finite or non-periodic signals. I would suggest you apply a window using 'hann' function to the time-domain signal before performing 'FFT' to obtain a smoother spectrum. The windowing process helps reduce spectral leakagge by tapering the beginning and end of the time-domain signal to zero.
The following code snippet may help you understand this:
% Creating a window
window = hann(Ns);
% Applying window function to the wave
Wave_windowed = Wave.*window;
% Performing fft
fft_Wave=fft(Wave_windowed);
fft_Wave = fft_Wave(1:Ns/2+1);
Kindly refer to the following documentation links to have more information on:

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by