Akzeptierte Antwort

Youssef  Khmou
Youssef Khmou am 29 Mai 2013

2 Stimmen

hi,
To reverse a vector try the function ' wrev' , here is an example :
r=wrev(1:4)
If you to control the degree of reverse/shifting try 'circshift' function.

2 Kommentare

Matthew Eicholtz
Matthew Eicholtz am 27 Jun. 2013
I like this solution. Does anybody know how fliplr and wrev differ in this particular case? Is one more computationally expensive than the other?
wrev(vect) -> vect(end:-1:1)
please try:
>> open wrev

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

Royi Avital
Royi Avital am 13 Jun. 2011

6 Stimmen

This might work as well (For 1D Vectors):
vReversed = v(end:-1:1);
Good luck!

3 Kommentare

Shweta Kanitkar
Shweta Kanitkar am 29 Mai 2013
v(end:-1:1) subtracts each element from v(end) by 1.
Walter Roberson
Walter Roberson am 28 Jun. 2013
Matt Eicholtz points out that Shweta's comment is incorrect; no subtraction is done, only indexing.
Cyrus David Pastelero
Cyrus David Pastelero am 8 Jul. 2020
This is what I am looking for. Thank you.

Melden Sie sich an, um zu kommentieren.

Walter Roberson
Walter Roberson am 13 Jun. 2011

2 Stimmen

fliplr() or flipud()
... But I suspect this is a class assignment. You will need to use your knowledge of MATLAB indexing and looping to work out your assignments for yourself.
goga
goga am 19 Nov. 2011

1 Stimme

use fliplr()

Kategorien

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by