reversing arrays

Discussion in 'MATLAB' started by Miguel Arthur, Nov 13, 2003.

  1. Hi, my question is: is there a simple way of reversing a 1xN matrix?
    I mean, without the use of a for loop.
    Thanks a lot.

    Miguel
     
    Miguel Arthur, Nov 13, 2003
    #1
    1. Advertisements

  2. Miguel Arthur

    Ken Davis Guest

    help fliplr
    help flipud
     
    Ken Davis, Nov 13, 2003
    #2
    1. Advertisements

  3. Ken, thanks a lot, that was what I was looking for.
    Miguel
     
    Miguel Arthur, Nov 13, 2003
    #3
  4. fliplr
    flipud


    Miguel Arthur () wrote:
    : Hi, my question is: is there a simple way of reversing a 1xN matrix?
    : I mean, without the use of a for loop.
    : Thanks a lot.

    : Miguel
     
    Geoffrey Egnal, Nov 13, 2003
    #4
  5. Miguel Arthur

    Jos Guest

    Same results, but ...
    elapsed_time =
    0.9400elapsed_time =
    2.4200

    hth,
    Jos
     
    Jos, Nov 14, 2003
    #5
  6. Well, yes... It's a given that a function call adds overhead. The
    whole key to vectorization is to use one function call instead of
    many, so the overhead is only incurred once, and the vast majority of
    the time is spent doing actual work.

    "Inlining" the code used inside an M-file will make a loop faster, no
    question. But fliplr is already vectorized in that it is seldom
    called inside a tight loop. So it probably doesn't matter.
     
    Peter Boettcher, Nov 14, 2003
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.