File Exchange

image thumbnail

GPS C/A Code Generator

version 1.1.0.0 (2.29 KB) by Dan Boschen
Generates C/A Codes for selected PRNs, up to 37 codes.

40 Downloads

Updated 01 Jun 2010

View License

G=CACODE(SV,FS)
G is a matrix with 1023*FS columns with a row for each PRN desired.
SV is a vector containing PRN numbers to be generated, from 1 to 37.
FS is the number of samples per chip desired in the code sequence. (Default=1).

Cite As

Dan Boschen (2020). GPS C/A Code Generator (https://www.mathworks.com/matlabcentral/fileexchange/14670-gps-c-a-code-generator), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (17)

Aleksey K

Hello

1-How one can get if we want to shift sv1= 345 chip , sv2= 23 chip and sv3= 795 chip then after that we want to generate the CA code for the GPS?
sv1=6
sv2=16
sv3=26
just provide me some hint?

I have change the first line of the code but it is not resulting the answer.

like i need for prn6 prn16 prn 26

so i have change it to
g=cacode([6 12]), in place of g=cacode(sv,fs), may i know sir what went wrong ?

For example to generate the C/A codes for PRN 6 and PRN 12 use:
% g=cacode([6 12]),
% and to generate the C/A codes for PRN 6 and PRN 12 at 5 MHz use
% g=cacode([6 12],5/1.023)

I have the same:
Error in cacode (line 48)
if (max(sv)>37) || (min(sv)<1) || (min(size(sv))~=1)
Can you help me?

I have this:

Error in cacode (line 48)
if (max(sv)>37) || (min(sv)<1) || (min(size(sv))~=1)

Can you help me?

Thank you Dan!

Its awesome man :) Thank you,great work ;)

Vl B

ok

AJ Hsu

It is really helpful

Dan Rutherford

Good job,
thanks for the leg up on learning about GPS

Jared Meadows

I think this is a wonderful function. I did encounter an column index error on line 116, and I think it's caused by floating point error when the ceil(cnt) is performed and ceil is ~ L. I was able to correct the problem with the following code:
if ceil(cnt) > L
gfs(:,index)=g(:,L);
else
gfs(:,index)=g(:,ceil(cnt));
end

Thanks for coding up the C/A algorithm.

liu bo

you have done a good job!

liu bo

without think about time clock,use FPGA to produce cacode maybe better.what do you think,Dan Boschen?

George James

I tried to run the code in matlab but I got the following error

Error in ==> cacode at 36
if (max(sv)>37) || (min(sv)<1) || (min(size(sv))~=1)

Pierre Gibouin

Great programm !

Updates

1.1.0.0

Updated author email address in comments.

1.0.0.0

Comment Correction.
Corrected "First Order Hold" to be "Zero Order Hold" in comments to reflect actual implementation.

Rev 1.2: Incorporated suggestion by Jared Meadows to fix possible floating point error when using fractional upsampling.

Corrected error with taps for PRN30, should be [2,7] and was incorrect as [1 7]. Thanks to Jadah Zak for finding this.

Minor corrections to previously submitted code.

MATLAB Release Compatibility
Created with R14SP2
Compatible with any release
Platform Compatibility
Windows macOS Linux