View full-text article in PMC Sensors (Basel). 2019 Oct 16;19(20):4495. doi: 10.3390/s19204495 Search in PMC Search in PubMed View in NLM Catalog Add to search Copyright and License information © 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/). PMC Copyright notice Algorithm 2 Welch’s Method Require: x[n]|n∈{0,1,⋯,N-1} Require: 0≤lseg≤N|∈N Require: 0≤lover≤N|∈N ----Splitthesignalx[n]intoKsegments. ----X[K]matrixforallsegments(K×(lseg)) X[K]←[][] K←N/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 pf∈Px[f] do Px[f]=pf/K end for return Px[f]