Matlab Code Fixes

Matlab cannot find functions deg2dms and dms2mat

These functions are part of the Matlab mapping toolbox which requires a dedicated toolbox license. Here you can download two functions that substitute these functions from the toolbox: deg2dms.mdms2mat.m. It is recommended to place these functions in the folder “GNSS_SDR/geoFunctions”.

Functions fxcorr, fxcorrBOC11, codephase, multipathBOC and acf_boc are missing

These functions are inside of the files Scurve.m and multEnvBOC.m respectively.

Function PRNgen.m is missing

Use the generateCAcode.m instead (from the “GNSS_SDR/include” folder).

Functions R.m and R_BL.m cannot be found by Matlab

Here are the download links for the two missing functions: R.m, R_BL.m.

The setting “Number of bytes to skip” cannot be set in the settings GUI

A variable is misspelled at line 180 in the file setSettings.m. The text settings.skipNuberOfBytes should be corrected to settings.skipNumberOfBytes.

Software falls into infinite loop after tracking, when 4 channels are selected

The problem occurs in one of the functions for coordinate transformations – the cart2geo.m. The function fails to approximate the height precise enough. The quick fix is to modify the function cart2geo.m as shown here (starting at line 30):

h = 0.1; oldh = 0;
iterations = 0;
while abs(h-oldh) > 1.e-12
   oldh = h;
   N = c/sqrt(1+ex2*cos(phi)^2);
   phi = atan(Z/((sqrt(X^2+Y^2)*(1-(2-f(i))*f(i)*N/(N+h)))));
   h = sqrt(X^2+Y^2)/cos(phi)-N;

   iterations = iterations + 1;
   if iterations > 100
       fprintf('Failed to approximate h with desired precision. h-oldh: %e.\n', h-oldh);

15 thoughts on “Matlab Code Fixes

  1. Currently trying to get satellite clock bias, position and velocity using the code, it seems that there is a bias…

  2. Hi

    Sorry to bother you. I have this book. and I did not see Scurve.m file and multEnvBOC.m file in the DVD. However, it can run and get some result. Does the software need these files? Thanks a lot!

    I also have a question for the SiGe front end, what kind of data format does this front end output to the computer? Thank you very much

    Best Regards

    1. Hi,

      Have you checked the “Figure files” folder? The two functions should be in that folder.

  3. Hello!
    I have the book of Chinese published in 2009, which provides the former version of SDR. I must say it’s so fabulous!
    Now I am working on the vector tracking , and I wonder where I can get the update software or the program of vector tracking?

    1. Hello,

      Dennis Akos has published a vector tracking SDR version on his project homepage at On that homepage open the “Front End Module” page and look for “VLL TRACKING” section in the upper part of the page.

      1. Sorry to bother you again…
        I run the VLL programe using the signal provided in the DVD, but the results of user’s position diverges. I tried a lot to fix it but didn’t work at all… Do you know what’s the problem and how to solve it?

        1. I am sorry, but I did not had a chance to try that VLL code. And at the moment I do not have time to look into this problem.

    1. Hi,

      We have Galileo and GLONASS versions which at the moment are not for publishing.

  4. Hi Darius, I wanted to add two additional fixes to the code provided with the book:

    1) calculatePseudoranges.m, line 60 had “for channelNr = 1:channelList.” 1:channelList resolves to “1” when channelList is a vector. A proper syntax is “for channelNr = 1:numel(channelList)” or “for channelNr = channelList”

    2) postNavigation.m, line 170 had size(activeChnList, 2). During the first call, activeChnList is a row vector (index ‘2’ is correct) successive calls are column vectors which should use index 1, ie size(activeChnList, 1). I changed it to numel(activeChnList) which is appropriate for both column and row vectors.

    With these two changes, the example “GPS_and_GIOVE_A-NN-fs16_3676-if4_1304.bin” works correctly.

  5. Hi,

    I am not sure you are still tacking care of this post but I’d thank you for useful information from the post.

    And I’d like to share my trouble and solution for the problem of Matlab version gap.

    There is a difference to use ‘intersect’ function. If you use Matlab after 2012, you should add ‘legacy’ flag with ‘intersect’ function for SDR GNSS source

    Like below,

    Before in postNavigation.m
    activeChnList = intersect(find(satElev >= settings.elevationMask), …

    Add ‘legacy’ flag,
    activeChnList = intersect(find(satElev >= settings.elevationMask), …

    1. Thank you very much,I have spend more time solve this problem before,now I can run correctly, thanks again!

Leave a Reply

Your email address will not be published. Required fields are marked *