2

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,

2 Answers 2

5

Need to use array merge and flip for subarray

A = 1:10
A = [A(1:5),fliplr(A(6:10))]
Sign up to request clarification or add additional context in comments.

Comments

5

You can try the following code, it uses the increment index :

d = [c(1:5), c(10:-1:6)]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.