How to create the complex representation from magnitude and phase information to perform an inverse fast fourier transformation (IFFT)?

Hello all!
I have a problem with converting amplitude and phase data into the complex form, which is required to perform an IFFT. (inverse fast fourier transformation). This is the only data I have. (See two pictures below)
My frequency range goes from 0.1 to 2.6 and, with 200 samples. I would like to use IFFT to obtain a time signal. Furthermore, can anyone advise me how to choose a time domain and sampling time in order to get useful results?
I have never used IFFT (Or fft) before, so some helpful insights would be very helpful!
<<
>>

답변 (1개)

Presuming that you want a real result after ifft:
The first value of the array should be the desired mean, multiplied by the total number of samples in the array.
The 2nd through N+1'st values should be complex values whose abs() is the desired magnitude and whose complex part is the desired phase.
After that there may be one real value
The remaining values should be the complex conjugates of the N+1'st through 2nd values (that is, take the N complex value and take conj(fliplr(X))
The total number of entries in the array will be even if you had that one real value, and will be odd if it was not present.
The number of points of output from the ifft will be the same as the length of the input.

댓글 수: 3

Thank you four your answer! I understand indeed that the first value gives information about the average, the next part represent the positive frequency, then the value at the nyquist frequency, followed by the values at negative frequencies. However,I have one more question. The amplitude in the frequency domain as obtained from the data (see graph), is this the same value as the abs(X) value when you would take the fft(X) from the time signal? Because in my case, this does not match. The same goes for phase information...
The amplitude in the frequency domain is complex, and you need to take its abs() to get the magnitude.
Possibly I do not understand your question. An example might help.
I will elaborate on my problem. I have a problem using the IFFT command. I want to see if i can go from the frequency domain to the time domain of a signal. I wanted to test this in two parts: 1) first creating a wave time domain-->using FFT to get the magnitude and phase in the frequency domain-->back to the time domain using IFFT.
2) Second, test to use the amplitude and phase of the wave (without information about the IFFT of the FFT of the wave signal in time domain), by creating a complex representation of the amplitude and phase. The amplitude 'zetaii'is different from fft(zeta)/length(zeta)
The complex representation in part 2) is different than the FFT of the time signal in part 1). What am I doing wrong in part 2)? Why is it different? Below I added the commented code( You can start from line 40 in the matlab code)
N=200; % No of different wave frequencies
t=0:199;
wmin=0.1; % lowest freq (rad/s) taken into account
wmax=2.6; % highest freq taken into account
W=wmin:(wmax-wmin)/(N-1):wmax;
w=transpose(W); %frequency
g=w*t;
wp=0.7854;
hs=4;
tp=8;
gamma = 3.3;
dw=(wmax-wmin)/(N-1); %delta w
sigma = zeros(N,1);
for i=1:N
if w(i)>wp
sigma(i) = 0.09;
else
sigma(i) = 0.07;
end
% the JONSWAP wave formula
A=exp(-((w(i)/wp-1)/(sigma(i)*sqrt(2))).^2);
S = 320*hs.^2*tp.^(-4)*w.^(-5).*exp(-1950/tp.^4*w.^(-4)).*gamma.^A;
%zetai=sqrt(S/w(i))/2;
g=w*t;
end % JONSWAP spectrum
%Discrete amplitudes over frequency
zetaii=sqrt(S.*2*dw);
%%Random phase creation
for i=1:N
phase1=2*pi*rand(i,1);
end
%%%%%%%%%%%%%%%%%%%%
%%%You can start looking from here%%%
%%%%%%%%%%%%%%%%%%%%
%%Wave generation
for i=1:length(t)
%wave elevation
zeti(:,i)=zetaii.*cos(g(:,i)+phase1(:,1)); %zetaii is the amplitude per wave component
zeta(1,i)=sum(zeti(:,i));
end
%%FFT process (towards frequency domain)
X=fft(zeta)/length(zeta); %FFT of the wave signal
X_mag=abs(X); %Magnitude of X in frequency domain
X_phase=angle(X); %Phase angle of X in frequency domain
%%IFFT process (back to time domain)
Z=X_mag.*exp(1j*X_phase);
XX=ifft(Z)*length(Z);
subplot(1,2,1)
plot(t,XX);
subplot(1,2,2)
plot(t,zeta)
%%Test to see if I can get from the freqency domain back to the time domain using only amplitude and phase information
ZZ=zetaii.*exp(1j*phase1); %%ZZ is different from X here, why?

댓글을 달려면 로그인하십시오.

카테고리

질문:

2015년 8월 10일

편집:

2015년 8월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by