Multiplication of complex numbers and ISTFT result
Mostra commenti meno recenti
Dear,
for what reason do I get complex double numbers as results after ifft in variable c1?
clear all
close all
clc
a = ones(1,128);
b = stft(a);
c = istft((b));
g = b .* (1 + 1i);
c1 = istft((g));
Thanks in advance!
5 Commenti
Marko Jankovic
il 2 Lug 2023
David Goodmanson
il 3 Lug 2023
Modificato: David Goodmanson
il 3 Lug 2023
Hi Marko,
You have
a = ones(1,128);
b = stft(a)
c = istft(b) --> ones(1,128) % <not quite, see comment below>
Both stft and istft are linear functions of their input, so you would expect that
c1 = istft(((1+i)*b)) = (1+i)*istft(b) --> (1+i)*ones(1,128)
which is exactly what happens. You can't make that complex factor just go away.
Hi David,
Not that it changes the substance of your comment, but c is not quite ones(1,128). The first element is zero. Just want to point this out because, unilke fft/ifft, stft and istft are not, in general, inverses of each other, which I learned when looking into this Question and thought might be of general interest.
a = ones(1,128);
b = stft(a);
c = istft(b);
c(1)
all(c(2:end))
David Goodmanson
il 3 Lug 2023
Hi Paul,
I did not see that for this case, thanks for pointing it out. But at least linearity still applies, so b --> (1+i)*b still results in c1 = (1+i)*c and the issue remains.
Risposte (1)
Mihir
il 2 Lug 2023
0 voti
The complex double numbers you are getting as results after the inverse Fast Fourier Transform (ifft) in variable c1 are likely due to the nature of the STFT (Short-Time Fourier Transform) and its inverse operation.
In the code you provided, you start with a vector a of ones and compute the STFT using the stft function. The STFT represents the signal in the frequency domain using complex numbers. Each complex number represents the magnitude and phase of a specific frequency component at a particular time. By default, the stft function returns a complex matrix where each element is a complex number.
Afterwards, you multiply the STFT matrix b by (1 + 1i), creating a new complex matrix g. This multiplication introduces additional complex components to the frequency-domain representation.
Finally, you apply the inverse STFT (istft) to g, resulting in c1. The inverse STFT attempts to reconstruct the original time-domain signal from the modified frequency-domain representation. Since the STFT and its inverse are not perfect, and the multiplication with (1 + 1i) introduces complex components, it's expected to get complex double numbers as the result in c1.
To summarize, the complex double numbers you see in c1 are a consequence of the STFT and its inverse operation, as well as the complex multiplication you performed on the STFT matrix. If you need a real-valued output, you may consider modifying your code accordingly.
1 Commento
Marko Jankovic
il 2 Lug 2023
Categorie
Scopri di più su Spectral Measurements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!