[Scilab-users] Copying an array

Antoine Monmayrant antoine.monmayrant at laas.fr
Mon Aug 5 15:31:37 CEST 2013


Hi Jack,

Sorry but I am not sure what you are trying to do.
Do you just want to copy an array (a_small) into a bigger one (a_big), 
starting at a given position?
If it's the case, you can do something like:

a_small=cumsum(ones(1,10));
a_big=zeros(1,20);
small=length(a_small);
nstart=5;
a_big(nstart+[1:small]-1)=a_small;//should check that nstart small 
enough and a_big big enough for a_small to fit in

But you might want something different.
If it's the case, try to rephrase your problem and maybe give an example.

Cheers,

Antoine


Le 02/08/13 00:16, cactus_jack a écrit :
> Hi, I'm pretty new to scilab and basically what I need to do is copy the
> following array into a new one but start the copying at the index that is
> half the interpx value, where interpx=64.
>
> The array is:
> data2 = zeros(1, bits*interpx); // initializing the array with dimensions
>
> I'm not really sure how to do this, but from what i can gather, I need to
> use a for loop.
>
> The reason i need to do this is, i need to convert the following QPSK
> modulation code into offset QPSK modulation. In Offset QPSK, the Q channel
> is shifted by half a time symbol so that the I and Q channel signals do not
> transition at the same time and in order to do this, i was told that I would
> need to do what i explained above.
>
> The complete code is as follows:
>
> interpx = 64;
> bits = 100;
> data = round(rand(1, bits));
> data1 = 2.*data - 1;
> data2 = zeros(1, bits*interpx); // initializing the arrays with dimensions
>
> for m = 1:interpx,
> data2(m:interpx:bits*interpx) = data1 //Bit fattening
> end
>
> t=0:1/2:(bits*interpx/2) - 1/2; //t=time
> carrier1 =  sin(t); //Q channel
> carrier2 =  cos(t); // I channel
> //scf(0)
> //plot(carrier1)
> //scf(1)
> //plot(carrier2)
> bpskwave1= (carrier1.*data2);//Q channel
> bpskwave2= (carrier2.*data2);//I channel
> //disp(bpskwave1)
> qpsk=(bpskwave1+bpskwave2)
> plot(qpsk)
> //plot(bpskwave2,bpskwave1)
>
> If anyone could show me how to do this, or show me an example or point me in
> the direction of some useful documentation, that would great. Thanks in
> advance.
>
>
>
> --
> View this message in context: http://mailinglists.scilab.org/Copying-an-array-tp4027149.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users




More information about the users mailing list