0
votes

I am working on some signals project and all I want to do is apply the fourier transform on a signal, get magnitude and phases and then change the phase matrix to something else say phasenew and then get the signal from magnitude and phasenew.

I am basing my code on Getting Fourier Transform from Phase and Magnitude - Matlab

>> F = fft(x);
>> mag =  abs(F);
>> phase = angle(F);
% Calculate phasenew using some algorithm, phasenew is very similar to phase, so output should be same.
>> re = mag .* cos(phasenew);
>> im = mag .* sin(phasenew);
>> F_i = complex(re,im);
>> x_i = ifft(F_i);

The output signal x_i is very different.

I found the similar problem here also : Fourier Transform: getting mag + phase then using those to plot original signal but in this link, I commented on the answer to ask @David about how should I proceed to solve the case of phasenew. He suggested me to ask this as a new question so here it is.

Please help me to generate the signal using inverse fourier transform from original magnitudes and new phases. Thanks in advance.

P.S. In phasenew I just shift the phase by either π/2 or -π/2.

1
Btw. If you just shift the phase by a constant it's the same as multiplying the original input with a fixed complex constant.Trilarion

1 Answers

0
votes

For me your approach works:

x = rand(100, 1);
y = fft(x);
mag = abs(y);
phase = angle(y);
y2 = mag .* (cos(phase) + 1i * sin(phase));
y3 = complex(mag .* cos(phase), mag .* sin(phase));
sum(abs(y-y2).^2)
sum(abs(y-y3).^2)
x2 = ifft(y2);
x3 = ifft(y3);
sum(abs(x - x2).^2)
sum(abs(x - x3).^2)

Gives values in the order of 1e-30, so all compared signals (y, y2, y3) and (x, x2, x3) are identical except for tiny numerical deviations.