# Matlab BOC (binary offset carrier)

I am trying to implement a binary offset carrier (BOC) direct sequence spread spectrum scheme in MATLAB. In that scheme, a code $c(t)$ (a binary vector which repeats after a certain number of zeros and ones) should be calculated by an other square (sub) carrier of the following form sign(sin(1*pi*fs*t) where fs is the subcarrier frequency and finally should be calculated by a carrier frequency having the usual form of a cosine.

I have generated the code needed (a vector of 1023 elements). These 1023 chips (vector’s elements) should be repeated every 1 ms in order for the chipping frequency to be achieved (10Mchips/s). After, that vector (code) should be multiplied by a square subcarrier of 1023 Mhz and finally by the ‘actual’ carrier (a co sinusoidal signal) of 4092 Mhz. All these should be demonstrated via plots.

My first problem is that in order to demonstrate the spectrum of the codes, spectral nulls should be represented at frequencies multiples of 1.023 Mhz. The only way that I could somehow think how to do this is to use massive vectors where are not really supported by my laptop's memory (RAM).

I say "somehow", because the sampling rate should change (for example wherever I have one ‘1’ I should add some more and the same applies to zeros). This procedure ruins the whole purpose of the code because the code has some particular autocorrelation properties which I don’t know if will continue to exist after.

Moreover, if that should reach the 10Mchips how will this could be done by using the particular vector. While I understand that it is easily done by using a random vector of 10*10^6 elements. Should I repeat the 1023 chips 1000 times?

• Didn't you ask a similar question a few weeks ago? – Dilip Sarwate Aug 30 '12 at 1:24
• Yes i did.I havent solve it yet. – Rizias Aug 30 '12 at 9:55

First off- I know you are doing you're best (which is why I am answering) but your question is very hard to read. Regardless of your English skills, it would be easier to read if you would break it up into paragraphs and throw in some pictures to help show what you're talking about.

These 1023 chips (vector’s elements) should be repeated every 1 ms in order for the chipping frequency to be achieved (10Mchips/s).

1023 chips repeated every 1 ms means you have $\frac{1023}{.001 s} =$1 Mchips/s, not 10 Mchips/s.

My first problem is that in the first place in order to demonstrate the spectrum of the codes,spectrul nulls should be represented at frequencies multiples of 1.023 Mhz.The only way that I could somehow think how to do this is to use massive vectors where are not really supported by my laptops memory (RAM).

You should not need a "massive" vector to demonstrate this. Increasing the number of samples that you FFT just gets you better frequency resolution- it doesn't change the frequency range. I think that you should be able to see the nulls just fine with several repetitions of the spreading code.

I say somehow because the sampling rate should change (for example wherever I have one ‘1’ I should add some more and the same applies to zeros).

I have no idea why you say that the sampling rate should change, unless you're talking about going from the unspread rate to the spread rate.

• First of all thank you for answering in my question.I think that that you say increasing the number of samples,is that i mean that i should change the sampling rate.Eg,the waveform should be kept 'high' for a longer period (meaning more ones) and and 'low' for an equal period (meaning more zeros added).This is the only way that i could represent the spectrum.If this is not what you mean the number of samples can you please get into trouble expand a bit on that? – Rizias Aug 30 '12 at 15:55
• @GiwrgosRizeakos When you "add" a zero you add samples- i.e. the number of samples increases. The sample rate does not change. – Jim Clay Aug 30 '12 at 18:00
• How do i change the sampling rate then,while if this is not done by putting more samples how is it done?Should i change the number of the initial vector's elements? – Rizias Aug 30 '12 at 19:17
• @GiwrgosRizeakos The process of changing the sample rate is called interpolation, decimation, or resampling. If you google those terms you should find some decent references. – Jim Clay Aug 30 '12 at 20:29

In your case, you are not simulating a continuous time signal. In general, however, if you simulate a continuous time signal, you have to increase the resolution of the arrays/vectors in MATLAB that are "continuous" signals so that these signals actually behave more like real-world continuous signals, e.g. to represent a continuous signal between say 0 and 32 on the time scale, your simulating vector/"continuous" signal could be between 0 and 2048 inclusive on an array as a representative of 0-32 on a continuous time scale. This would give a time resolution of 1/64. You could then approximately simulate sampling by taking samples out, but only after band-limiting first.