I think I may have figured out the answer. I need to use the complex conjugate for the sigfft(44100+1-200*i) assignment.
Generate Real Signal With Random Phase and Specified Modulus at 10 Harmonics
5 views (last 30 days)
Show older comments
Hi all,
I want to create a 1 sec duration real signal with 10 harmonics of a specified modulus and randomized phase. Here's what I've done:
phase = [2*rand(1)*pi - pi, ... , 2*rand(1)*pi - pi]; % ... is 8 repetitions
modulus = [1000, ... , 1000]; % ... is 8 repetitions
real = sqrt(modulus.^2./([1,1,1,1,1,1,1,1,1,1]+tan(phase).^2)); % substitute and calculate real part first
imag = sqrt(modulus.^2 - real.^2); % solve for imag part
sigfft = zeros(44100,1);
for i = 1:10
sigfft(1+200*i) = real(i) + j*imag(i); % j = sqrt(-1) previously assigned
sigfft(44100+1-200*i) = real(i) + j*imag(i);
end
sig = ifft(sigfft);
Thus, I assign a random phase in the interval [-pi,pi), and find the imaginary and real parts which correspond to the assigned random phase and the specified modulus of 1000. Then I code these into the 10 harmonic bins of 200Hz, 400Hz, ... , 2000Hz. However, when I execute sig = ifft(sigfft), Matlab returns a complex signal. I want a real signal, what's going on here?
Answers (1)
See Also
Categories
Find more on Octave in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!