how do i reverse a vector
568 views (last 30 days)
Show older comments
ken masters
on 13 Jun 2011
Commented: Cyrus David Pastelero
on 8 Jul 2020
so far i have this
function [Vout]=reverse(Vin)
0 Comments
Accepted Answer
Youssef Khmou
on 29 May 2013
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 Comments
Matthew Eicholtz
on 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?
Andrei Bobrov
on 28 Jun 2013
wrev(vect) -> vect(end:-1:1)
please try:
>> open wrev
More Answers (3)
Royi Avital
on 13 Jun 2011
This might work as well (For 1D Vectors):
vReversed = v(end:-1:1);
Good luck!
3 Comments
Walter Roberson
on 28 Jun 2013
Matt Eicholtz points out that Shweta's comment is incorrect; no subtraction is done, only indexing.
Walter Roberson
on 13 Jun 2011
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.
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!