If I have an array
>> c = 1:10
c =
1 2 3 4 5 6 7 8 9 10
How do I reverse the last five elements, so that my new array is
c =
1 2 3 4 5 10 9 8 7 6
Thank you,
Need to use array merge and flip for subarray
A = 1:10
A = [A(1:5),fliplr(A(6:10))]
You can try the following code, it uses the increment index :
d = [c(1:5), c(10:-1:6)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With