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.

15 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).

Comments and Ratings (14)

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