Creating a random vector in MATLAB

I am trying to create a random frequency spectrum, and then use ifft to find the corresponding time-domain vector.

I am using the following code:

 for i = 1:64 randNum = (rand() + 1i * rand())/sqrt(2); % Needs to be normalized by sqrt(2) randFreq(i) = randNum; end randVec = ifft(randFreq); 

Note that I know mvnrnd , however for technical reasons I need to use a for loop and generate each element individually. I also need to generate a random frequency spectrum, and then use the inverse transform, I can not directly generate a random vector in the time domain.

If I draw a random vector value ( plot(abs(randVec)) ), I always get a graph of this form.

enter image description here

There is always a surge in n=0 , and all other elements are much smaller in magnitude. I was hoping for some understanding of why this is happening.

My question is not a duplicate. Creating random values ​​in vector Matlab , these are completely different questions, which, as it turned out, are on the same topic. I specifically ask about the behavior of my ifft . This is not a duplicate of the surge in my inverse Fourier transform . In this matter, the spike may be caused by some data identity, however in my case the data is completely random.

+5
source share
1 answer

As you generate random values ​​for the frequency components, they are not symmetrically distributed around zero. In particular, the resulting real and imaginary parts have an ideal average of .5/sqrt(2) . The actual (approximate) average value will be close to this.

When using IDFT, the average value over all frequencies corresponds to the first sample in the time domain. To see this, set n = 0 in the IDFT expression:

enter image description here

Thus, you get a larger absolute value in this first sample, because the average in frequency is greater than the β€œshould”.

+5
source

Source: https://habr.com/ru/post/1274485/


All Articles