# A Design Method of Code Correlation Reference Waveform in GNSS Based on Least-Squares Fitting
## 2 Least-Squares Method of S-Curve Shaping
\(W(t)\) can be described as a combination of series of base strobe waveform \(g_{0}(t)\), as shown in Figure 5.  
\[W(t) = \sum_{i=1}^{N}\gamma_{i}W_{i}(t)\] \[\tilde{X}(t) = X(t)\otimes h(t) \tag{2}\]0 \[\tilde{X}(t) = X(t)\otimes h(t) \tag{2}\]1 \[\tilde{X}(t) = X(t)\otimes h(t) \tag{2}\]2  
\[\tilde{X}(t) = X(t)\otimes h(t) \tag{2}\]3 Waveforms of different code correlation reference waveforms. Here, \(d_{i}\) is the time delay of the \(i\)-th base strobe waveform, and \(\gamma_{i}\) is the weight of the \(i\)-th base strobe waveform. \(W_{0}(t)\) is a CCRW with the strobe waveform placed at the start of each code chip. In this process, \(W(t)\) is manually constructed. Assume \(-LT_{c}\) is the initial point of \(g(t)\); the base strobe waveform length is \(\mu\); and \(N\) is the number of base strobe waveforms in \(g(t)\). Notably, \(N\mu\) should not exceed the single code chip. The \(R_{\bar{X}W}\) can be considered as a convolution result between \(\bar{X}(t)\) and \(W_{\Sigma}(t)\). \[W_{\Sigma}(t)=\left\{ \begin{array}{ll}W(T-t)&0<t<T\\ 0&\text{otherwise}\end{array} \right. \tag{7}\]  
The Fourier transform of \(R_{\bar{X}W}(\varepsilon)\) can be expressed as a linear combination of time-shifted \(R_{\bar{X}W_{0}}(\varepsilon)\) filtered by \(h(t)\). \[FT\left\{R_{\bar{X}W}(\varepsilon)\right\} = FT\left\{\bar{X}(t)*W_{\Sigma}(t)\right\} \tag{8}\] \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\] \[= H(j\omega)FT\left\{\sum_{i=1}^{N}\gamma_{i}X(t)*W_{i}(t)\right\}\] \[= H(j\omega)FT\left\{\sum_{i=1}^{N}\gamma_{i}R_{XW_{0}}( \varepsilon+d_{i})\right\}\]  
Here, \(FT\{x\}\) is the Fourier transform of \(x\). The coherent and non-coherent discriminator can be expressed as follows. \[D_{c}(\varepsilon) = R_{\bar{X}W}(\varepsilon)\cos\varphi_{e} \tag{9}\] \[= \sum_{i=1}^{N}\gamma_{i}R_{\bar{X}W_{0}}(\varepsilon+d_{i})\cos \varphi_{e}\] \[D_{nc}(\varepsilon) = R_{\bar{X}X}(\varepsilon)\sum_{i=1}^{N}\gamma_{i}R_{\bar{X}W_{0 }}(\varepsilon+d_{i})\cos\varphi_{e}\]  
As implied by Equation (9), the S-curve is shaped by setting \(\gamma_{i}\) of \(W_{i}(t)\). The ideal S-curve \(D_{ideal}(\varepsilon)\) can be concluded with the following characteristics. 1. Unbiased tracking point, i.e., \(D_{ideal}(0)=0\). 2. Linearity around the tracking point, i.e., \(D_{ideal}(\varepsilon)=\varepsilon\), for \(|\varepsilon|\leq pT_{c}\). 3. Zero value left to the pull-in region, i.e., \(D_{ideal}(\varepsilon)=0\), for \(\varepsilon<-pT_{c}\). Figure 5: Schematic diagram of the code correlation reference waveform. Avoiding the false lock point, i.e., \(D_{ideal}(\varepsilon)\geq 0\), for \(\varepsilon>0\). Here, \(T_{c}\) is the width of the single code chip, and \(pT_{c}(0<p<1)\) is the unilateral range of the linear region. To find the best \(W(t)\) that suits the ideal S-curve in band-limited situations, the least-squares method is utilized to fit \(D_{ideal}(\varepsilon)\) by a finite amount of weights, as expressed in Equation (10). \[\boldsymbol{\gamma} = \min_{\boldsymbol{\gamma}\in\mathbb{R}^{N}}\|D(\varepsilon)-D_{ ideal}(\varepsilon)\|\] \[\varepsilon = [-KT_{c},-KT_{c}+\Delta\tau,-KT_{c}+2\Delta\tau,...,KT_{c}]^{T} \tag{10}\]  
Here, \(\pm KT_{c}\) is the fitting range of the S-curve for the optimization process, and the length of \(\varepsilon\) is \(M\). Combing Equations (9) and (10), the problem can be simplified as finding the solution \(\mathbf{x}_{LS}\) to \(\mathbf{A}\mathbf{x}=\mathbf{b}\) for the coherent discriminator, and \(\mathbf{P}\mathbf{A}\mathbf{x}=\mathbf{b}\) for the non-coherent discriminator. \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]0 \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]1 \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]2 \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]3  
Here, \(diag(x_{1},x_{2},...,x_{M})\) stands for the diagonal matrix consisting of \(x_{1},x_{2},...,x_{M}\).