Frequency domain response from time domain response using PSD

5 ビュー (過去 30 日間)
Mohammed Iqbal
Mohammed Iqbal 2022 年 2 月 28 日
回答済み: Balavignesh 2024 年 1 月 11 日
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 Center および File ExchangeFourier Analysis and Filtering についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by