Effacer les filtres
Effacer les filtres

how do i reverse a vector

228 vues (au cours des 30 derniers jours)
ken  masters
ken masters le 13 Juin 2011
so far i have this
function [Vout]=reverse(Vin)

Réponse acceptée

Youssef  Khmou
Youssef Khmou le 29 Mai 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 commentaires
Matthew Eicholtz
Matthew Eicholtz le 27 Juin 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
Andrei Bobrov le 28 Juin 2013
wrev(vect) -> vect(end:-1:1)
please try:
>> open wrev

Connectez-vous pour commenter.

Plus de réponses (3)

Royi Avital
Royi Avital le 13 Juin 2011
This might work as well (For 1D Vectors):
vReversed = v(end:-1:1);
Good luck!
  3 commentaires
Walter Roberson
Walter Roberson le 28 Juin 2013
Matt Eicholtz points out that Shweta's comment is incorrect; no subtraction is done, only indexing.
Cyrus David Pastelero
Cyrus David Pastelero le 8 Juil 2020
This is what I am looking for. Thank you.

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 13 Juin 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.

goga
goga le 19 Nov 2011
use fliplr()

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by