# A Design Method of Code Correlation Reference Waveform in GNSS Based on Least-Squares Fitting
## 2 Least-Squares Method of S-Curve Shaping
The coefficient matrix \(\mathbf{A}\in\mathbb{C}^{M\times N}\) is comprised of correlation functions \(R_{\tilde{X}W_{0}}\), the observation matrix \(\mathbf{b}\in\mathbb{R}^{M}\) and the unknowns' vector \(\mathbf{x}\in\mathbb{R}^{N},M\geq N\). In the band-limited situations, \(\mathbf{A}\) is often ill-conditioned or rank defected, as can be seen in \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]4 The coefficient matrix \(\mathbf{A}\) is ill-conditioned if the condition number \(\kappa(\mathbf{A})\) in Equation (12) is too large. Then, the error mean square for the regression coefficient will largely increase, and as a consequence, the regression fitting will have poor robustness and low precision. That is, for any tiny disturbances \(\delta\mathbf{A}\) and \(\delta\mathbf{b}\), the resolution of \((\mathbf{A}+\delta\mathbf{A})\mathbf{x}=\mathbf{b}+\delta\mathbf{b}\) is distinct from the solution of \(\mathbf{A}\mathbf{x}=\mathbf{b}\). However, there are always some differences between the coefficient matrix \(\mathbf{A}\) in the simulations and the actual coefficient matrix \(\mathbf{A}\) for a real receiver, because of the non-ideal device characteristics or non-ideal channel impulse response. If \(\mathbf{A}\) is ill-conditioned in the least-squares approximation, the solution would be quite different from the genuine solution. Therefore, the corresponding output in the receiver may not be what is expected. Furthermore, the computational accuracy is limited in the mathematical software; an ill-conditioned problem is probably inaccurate in the software calculation. \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]5 \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]6 \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]7 \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]8  
A truncated singular value decomposition (SVD) method is utilized to find \(\mathbf{x}_{LS}\) in this LS problem and to avoid the ill-conditioned problem of the coefficient matrix. \[= X(j\omega)H(j\omega)W_{\Sigma}(j\omega)\]9 \[= H(j\omega)FT\left\{\sum_{i=1}^{N}\gamma_{i}X(t)*W_{i}(t)\right\}\]0  
Here, \(\mathbf{A}_{k}^{\dagger}\) is the Moore-Penrose (MP) inverse of \(\mathbf{A}_{k}\), and its SVD is \(\mathbf{U_{1}}\), \(\mathbf{\Sigma_{1}}\) and \(\mathbf{V_{1}}\). The process of the proposed method can be concluded in the following. * Do the SVD of \(\mathbf{A}=\mathbf{U}\mathbf{\Sigma}\mathbf{V}^{\mathbf{H}}\), where \(\mathbf{\Sigma}=diag(\sigma_{1},...,\sigma_{r},0,...,0),\sigma_{1}\geq...\geq \sigma_{r}>0\) and \(rank(\mathbf{A})=r\). * Set the measurement of uncertainty of \(\mathbf{A}\) to be \(tol=1e^{-5}\). * Find \(\mathbf{A}_{k}=\mathbf{U}_{\mathbf{1}}\mathbf{\Sigma}_{\mathbf{1}}\mathbf{V} _{\mathbf{1}}^{\mathbf{H}}\), where \(\mathbf{\Sigma}_{1}=diag(\sigma_{1},...,\sigma_{k}),\sigma_{1}\geq...\geq \sigma_{k}>\sigma_{1}tol>\sigma_{k+1}\geq...\geq\sigma_{r}\). \(\mathbf{U}_{\mathbf{1}}\) and \(\mathbf{V}_{\mathbf{1}}\) are the first \(k\) columns of \(\mathbf{U}\) and \(\mathbf{V}\). * According to the Equation (13), the approximated minimal norm solution \(\overline{\kappa}_{LS}\) is acquired. The measurement of uncertainty \(tol\) is employed to exclude the minimal singular value in the ill-conditioned matrix \(\mathbf{A}\). The approximate error \(\|\mathbf{A}-\mathbf{A}_{k}\|=\sigma_{k+1}<\sigma_{1}tol\). Take the least-squares solution for the BPSK(1) signal with an 8.184-MHz bandwidth as an example. The resulting S-curve of proposed method is shown in Figure 7, compared to the resulting S-curve acquired by the traditional least-squares solution with the ill-conditioned coefficient matrix. The resulting S-curve of the proposed method can reproduce the target S-curve, but the result in the ill-conditioned case is inaccurate and unusable. Moreover, the proposed S-curves calculated with different data precisions are shown in \[= H(j\omega)FT\left\{\sum_{i=1}^{N}\gamma_{i}X(t)*W_{i}(t)\right\}\]1 This shows that there is little difference in the results when the coefficient matrix varies slightly.