Skip to main content
. 2019 Oct 16;19(20):4495. doi: 10.3390/s19204495
Algorithm 2 Welch’s Method
  • Require:  x[n]|n{0,1,,N-1}

  • Require:  0lsegN|N

  • Require:  0loverN|N

  •    ----Splitthesignalx[n]intoKsegments.

  •    ----X[K]matrixforallsegments(K×(lseg))

  •    X[K][][]

  •    KN/lseg

  •    X[K]=split(x[n],lseg,lover){k[1,,K]}

  •    ----Convolveeachsegmentxk[t]withw[n]

  •    ----ComputetheFFTofxk[n]

  •    ----F(jω)matrixforfrequencypower(K×(lseg/2))

  •    F(jω)[][]

  •    for  xk[n]X[K]  do

  •       (xk*w)[n]=convolve(xk[n],w[n])

  •       F(jωk)=FFT(xk[n])

  •    end for

  •    ----Computefrequencyvalues

  •    Fx=0:(fs/2)×1/(lseg/2):fs/2

  •    ----Foreachfrequencycomputesquaredmagnitude

  •    Px[f][]

  •    for  f[0,,fs/2]  do

  •       for fk[i]F(jw)  do

  •         Px[f]+=fk[f]2

  •       end for

  •    end for

  •    ----Computeaveragevalues

  •    for  pfPx[f] do

  •      Px[f]=pf/K

  •    end for

  •    return  Px[f]