how to sample and modulate a gps gold code
Have a look to the definition of the C/A signal here: where it says t you need to put your time, where it says i, you need to put your index i  from the for loop, so that concept is correct. 

I think your confusion comes from using the frequency in the equation instead of the sampling time which is your time vector.