real data FFT and reconstruction - frequency base issues

41 visualizaciones (últimos 30 días)
VMat
VMat el 7 de Oct. de 2016
Respondida: David Goodmanson el 28 de Jun. de 2021
Hello, and thanks for your time on the following.
I wish to perform FFT and reconstruct the signal 'eta' generated by the script available at http://benjaminbiegel.com/files/oceanWaveGeneration.zip
Three main issues:
  1. Sampling rate and frequency interval to produce and plot FFT are not correct
  2. Struggling with signal reconstruction, no clue on how to obtain the original (random) signal
  3. plots axes values appear completely out of scope...
Went through lots of pertinent web posts and trials before asking here. Could you please guide me through to a meaningful solution? And possibly point out to the conceptual errors.
Many thanks.
ATTEMPT CODE
% t is the time series, defined in the above script
fs = 1/Ts; % Ts is defined in the above script
x = eta; % eta is the original signal for transform and reconstruction
X = fft(x);
n = length(x); % so length of frequency series equal to length of time series to plot X correctly
c = (-1 * fs) / 2:fs / n:fs / 2 - fs / n; % generates the frequency series to plot X in frequency domain
mag=abs(X);
ph=angle(X);
rec=mag.*exp(i*ph);
rec=ifft(rec);
%%pseudo code for plotting
% original signal
plot(t,x)
% magnitude
plot(c,fftshift(abs(X))
% phase response
plot(c,angle(X))
% real part of Fourier spectrum
plot(c,real(X))
% reconstructed signal
plot(t,rec)
% reconstruction by magnitude
plot(ifftshift(ifftn(mag)))
% reconstruction by phase
plot(ifft(exp(1i*ph)))
  1 comentario
vimal kumar chawda
vimal kumar chawda el 24 de Jun. de 2021
your information is not complete, can you please rephrase the data and questions

Iniciar sesión para comentar.

Respuestas (1)

David Goodmanson
David Goodmanson el 28 de Jun. de 2021
Hi Vmat.
I believe that with 'rec' you may be confusing the time and frequency domains. The code below uses rec for the time domain quantity and rec_f for the freq domain quantity.
First of all, both the time and frequency axes depend only on Ts, so if the scaling seems wrong you will have to go back to the original paper and verify Ts. The frequency scale c is correct, although typographically I think something like in the code below is clearer.
For the magnitude in the frequency domain you may want to use
X = fft(x)/n;
which is common. That will require multiplying the ifft by n in order to make up for the 1/n.
It simply does not work to do an ifft on either magnitude or phase separately in order to reconstruct something in the time domain. It only works to do the ifft on the complex quantity, rec_f in this case.
Ts = 1e-3; % arbitrary
fs = 1/Ts;
n = 1000;
t = (0:n-1)*Ts;
x = sin(100*(t/Ts).^2/n^2);
figure(1)
plot(t,x); grid on
X = fft(x);
% generates the frequency series to plot X in frequency domain
c = -fs/2 : fs/n : fs/2-fs/n;
mag = abs(X);
ph = angle(X);
rec_f = mag.*exp(i*ph);
% original signal
figure(1)
plot(t,x); grid on
% frequency domain plots
% note that since x is real, mag and real are even functions of f and
% angle and imag are odd functions of f
% magnitude
figure(2)
plot(c,fftshift(abs(X))); grid on
% phase response
figure(3)
plot(c,fftshift(angle(X))); grid on
% real part of Fourier spectrum
figure(4)
plot(c,fftshift(real(X))); grid on
% imaginary part of Fourier spectrum
figure(5)
plot(c,fftshift(imag(X))); grid on
% reconstruction in time domain
rec = ifft(rec_f);
figure(6)
plot(t,x,t,rec,'o'); grid on % compare

Categorías

Más información sobre Fourier Analysis and Filtering en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by