Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 125397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:09:09+00:00 2026-05-11T05:09:09+00:00

Given an array: array1 = [1 2 3]; I have to reverse it like

  • 0

Given an array:

array1 = [1 2 3]; 

I have to reverse it like so:

array1MirrorImage = [3 2 1]; 

So far I obtained this ugly solution:

array1MirrorImage = padarray(array1, [0 length(array1)], 'symmetric', 'pre'); array1MirrorImage = array1MirrorImage(1:length(array1)); 

Is there a prettier solution to this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T05:09:10+00:00Added an answer on May 11, 2026 at 5:09 am

    UPDATE: In newer versions of MATLAB (R2013b and after) it is preferred to use the function flip instead of flipdim, which has the same calling syntax:

    a = flip(a, 1);  % Reverses elements in each column a = flip(a, 2);  % Reverses elements in each row 


    Tomas has the right answer. To add just a little, you can also use the more general flipdim:

    a = flipdim(a, 1);  % Flips the rows of a a = flipdim(a, 2);  % Flips the columns of a 

    An additional little trick… if for whatever reason you have to flip BOTH dimensions of a 2-D array, you can either call flipdim twice:

    a = flipdim(flipdim(a, 1), 2); 

    or call rot90:

    a = rot90(a, 2);  % Rotates matrix by 180 degrees 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of ints like this: [32,128,1024,2048,4096] Given a specific value, I
This problem is taken from interviewstreet.com Given array of integers Y=y1,...,yn, we have n
So let's say I have this array: $requiredFruit= @(apple,pear,nectarine,grape) And I'm given a second
Let's say I have an array like this: $array = array ('1','2','3','4'); And I
I have an array of pairs like this: [[a, b], [b, d], [a, c],
Hello frnds actually i have a array of arrays as given below:-` parrent array{
Given an array of ids $galleries = array(1,2,5) I want to have a SQL
I have an array with allowed values and an array with given values. Howto
I have a homework question that says: Problem 1: Given the array [ 22
I have a Width and Height parametr. I have been given an array of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.