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);
       break;
   end
end

16 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?
    THX!

    1. Hello,

      Dennis Akos has published a vector tracking SDR version on his project homepage at http://ccar.colorado.edu/gnss/. 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?
        THX!

        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), …
    readyChnList);

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

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

  6. My friend told me to check the code of matlab. But I have not studied GNSS. Thank you very much for having this book ‘A Software-Defined GPS and Galileo Receiver: A Single-Frequency Approach’.And it also has a Chinese version! The code is working fine in MATLAB 7. I started to adapt the code to MATLAB 2017a.
    1、postNavigation.m:
    %% Decode ephemerides
    for channelNr = activeChnList
    This ‘for’ loop should be modified to:
    for channelNr = 1:numel(activeChnList)
    We know that activeChnList = [1,2,3,4,5,6,7,8].channelNr should be 1 or 2 or 3 or 4…. But it does not work in Matlab 2017. channelNr becomes [1,2,3,4,5,6,7,8].

    2、calculatePseudoranges.m:
    The same problem.
    %— For all channels in the list …
    for channelNr = channelList
    This ‘for’ loop should be modified to:
    for channelNr = 1:numel(channelList)

    3、postNavigation.m:
    activeChnList = intersect(find(satElev >= settings.elevationMask),readyChnList);
    Firstly,satElev=[inf,inf,inf,inf,inf,inf,inf,inf].
    After intersect(),activeChnList = [1,2,3,4,5,6,7,8].
    And after satElev = navSolutions.channel.el(:, currMeasNr);
    satElev = [number_A;
    number_B;
    number_C;
    ……;
    number_H]
    Secondly,after intersect(),row matrix becomes vertical matrix.
    activeChnList = [1;
    2;
    3;
    4;
    5;
    6;
    7;
    8]
    So,when the code: If the number of columns in the vertical matrix is greater than 3.
    if size(activeChnList, 2) > 3 —> if 1 > 3
    Therefore,the code can be modified to:
    activeChnList = intersect(find(satElev >= settings.elevationMask), …
    readyChnList,’legacy’);

    Or
    activeChnList = intersect(find(satElev >= settings.elevationMask), …
    readyChnList);
    if size(activeChnList,2) == 1
    activeChnList = activeChnList’;
    end
    The reasons for these code errors is that I run it on matlab7 and compare it on matlab2017a sentence by sentence.I hope everyone can forgive my poor English and hope that these sharing can help everyone.

Leave a Reply to ahlangzai Cancel reply

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