Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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))]
Add a comment
You can try the following code, it uses the increment index :
:
d = [c(1:5), c(10:-1:6)]
Required, but never shown
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.
Explore related questions
See similar questions with these tags.