IAGO SESTREM Ochoa - 4 months ago 25

C Question

I have a vector A with 6 positions with respective values {10,20,30,40,50,60}, and initially I have a vector B of 4 positions with the respective values {0,0,0,0}, My problem is that I need to transpose the values from vector A to vector B in reverse order. Using a for-loop would look like this:

`i = 0:`

B = {10,0,0,0}

i = 1:

B = {20,10,0,0}

i = 2:

B = {30,20,10,0}

i = 3:

B = {40,30,20,10}

i = 4:

B = {50, 40, 30, 20}

i = 5:

B = {60,50,40,30}

I'm doing this to implement a vibrato audio effect in C ,I have the algorithm in Matlab, in Matlab there is a specific function for this, which is:

`B = [A (n); B (1: L-1)];`

For:

`N = size of A`

L = size of B

So, could anyone tell me if there is any function ready to do this in C?

Answer

No, there is no ready function to do this in C. You will need to write a simple function that returns an array of 4 values (integers? hard to say) and accepts an array of 6 values. You may be able to find an external library that does this for you, but I doubt it because of the simplicity of this function.