0
$\begingroup$

EDIT

The first version of my question has not worked as I expected, so that I will try to be a little bit more specific.

The final goal I am trying to achieve is the generation of a ten minutes time series: to achieve this I have to perform an FFT operation, and it's the point I have been stumbling upon.

Generally the aimed time series will be assigned as the sum of two terms: a steady component $U(t)$ and a fluctuating component $u^{'}(t)$. That is

$$u(t) = U(t) + u^{'}(t);$$

So generally, my code follows this procedure:

1) Given data

$time = 600 [s];$

$Nfft = 4096;$

$L = 340.2 [m];$

$U = 10 [m/s]$

$df = 1/600 = 0.00167 Hz;$

$f_{n} = Nfft/(2*time) = 3.4133 Hz;$

This means that my frequency array should be laid out as follows:

$$ f = (-f_{n}+df):df:f_{n} $$

But, instead of using the whole $f$ array, I am only making use of the positive half:

$$ f_{+} = df:f_{n} = 0.00167:3.4133 Hz; $$

2) Spectrum Definition

I define a certain spectrum shape, applying the following relationship

$$ S_{u} = \frac{6L/U}{(1 + 6f_{+}L/U)^{5/3}}; $$

3) Random phase generation

I, then, have to generate a set of complex samples with a determined distribution: in my case, the random phase will approach a standard Gaussian distribution $(\mu = 0, \sigma = 1)$.

In MATLAB I call

nn = complex(normrnd(0,1,Nfft/2),normrnd(0,1,Nfft/2));

4) Apply random phase

To apply the random phase, I just do this

$$ H_{u} = S_{u}*nn; $$

At this point start my pains!

So far, I only generated $Nfft/2 = 2048$ complex samples accounting for the $f_{+}$ content. Therefore, the content accounting for the negative half of $f$ is still missing. To overcome this issue, I was thinking to merge the $real$ and $imaginary$ part of $H_{u}$, in order to get a signal $H_{uu}$ with $Nfft = 4096$ samples and with all real values.

But, by using this merging process, the $0-th$ frequency order would not be represented, since the $complex$ part of $H_{u}$ is defined for $f_{+}$.

Thus, how to account for the $0-th$ order by keeping a procedure as the one I have been proposing so far?

$\endgroup$
3
  • 2
    $\begingroup$ What are you trying to achieve? What is your starting data? what should it look like at the end? There are snippets of lucidity in your question, but the overall impression is one of complete confusion (for me!). Start simple, work up to the final thing... $\endgroup$
    – Peter K.
    Commented May 7, 2013 at 19:46
  • $\begingroup$ For a start, if you have $N$ samples in the frequency domain, you're usually interested in frequencies $-N/2+1, -N/2+2,\ldots,-1,0,1,\ldots,N/2$ (for $N$ even). $\endgroup$
    – Peter K.
    Commented May 7, 2013 at 19:48
  • 1
    $\begingroup$ @PeterK. : I edited my question; I hope it's any clearer by now. $\endgroup$
    – fpe
    Commented May 8, 2013 at 10:41

2 Answers 2

1
$\begingroup$

There is still lots of issues with what you're trying to achieve, but it's a little clearer for me now. Thanks for the edit.

  1. DC term: You say $$ u(t) = U(t) + u^{'}(t); $$ with $U = 10 [m/s]$. Surely the constant $U$ is your "DC" (zeroth order) term?

  2. Sampling Rate: You say that $time = 600$ and that $Nfft = 4096$. Does that make your sampling rate $f_s = 4096 / 600 = 6.8267$ Hz?

  3. df Choice: I am not sure why you choose $df = 600$ ?

  4. Random Phase Generation: Your phase generation seems odd to me. This nn = complex(normrnd(0,1,Nfft/2),normrnd(0,1,Nfft/2)); will not generate just random phase. It will also generate a random amplitude, which is not what you want if you're just after phase. To get a random phase, you're better off doing: nn = exp(1j*2*pi*rand(1,Nfft/2)). That generates Nfft/2 uniform random variables (between 0 and 1), multiplies them by $2\pi$ and then forms $e^{j2\pi\times \mathrm{rand(1,Nfft/2)}}$.


How to account for the DC term?

If your (positive-frequency) spectrum is $H_n(f)$ for $f= k df$ for $k=1,\ldots,Nfft/2$, then just form:

$$ \begin{array} \ H(f) &=& U, \mathrm{for\ } f=0\\ &=& H_n(f), \mathrm{for\ } f>0\\ &=& H^*_n(-f), \mathrm{for\ } f<0 \end{array} $$

$\endgroup$
3
  • $\begingroup$ To answer your questions: 1) DC term: yes $U$ is the 0-th order term; 2) Sampling Rate: $f_{s} = 6.8267$, but $f_{n} = f_{s}/2$; 3) $df = 0.00167 Hz$; $\endgroup$
    – fpe
    Commented May 8, 2013 at 20:24
  • $\begingroup$ 4) this way, merging real and imaginary part, the FFT will retrieve a periodic time series, but I need exactly $Nfft$ independent samples. $\endgroup$
    – fpe
    Commented May 8, 2013 at 20:28
  • $\begingroup$ @fpe Regarding 4), your existing method will not do what you are saying it will do. If your final signal is to be real-valued, then you cannot have $Nfft$ independent phases. The phases must be conjugate-symmetric. $\endgroup$
    – Peter K.
    Commented May 8, 2013 at 20:32
1
$\begingroup$

To get a real signal valued time domain signal: create the negative frequencies as the complex conjugate of the positive frequencies

To get a complex time domain signal: create negative frequencies by copying the amplitudes of the positive frequencies and applying a random phase.

If you construct the signal in frames you will been apply windowing and overlap to avoid discontinuities at the frame boundaries.

$\endgroup$
1
  • $\begingroup$ I'm already creating the negative frequency content by means of the conjugate of the positive frequencies. But where is the 0-th order? since the positive frequencies don't involve it at all. $\endgroup$
    – fpe
    Commented May 8, 2013 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.