Borrar filtros
Borrar filtros

how do i reverse a vector

219 visualizaciones (últimos 30 días)
ken  masters
ken masters el 13 de Jun. de 2011
Comentada: Cyrus David Pastelero el 8 de Jul. de 2020
so far i have this
function [Vout]=reverse(Vin)

Respuesta aceptada

Youssef  Khmou
Youssef Khmou el 29 de Mayo de 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 comentarios
Matthew Eicholtz
Matthew Eicholtz el 27 de Jun. de 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 el 28 de Jun. de 2013
wrev(vect) -> vect(end:-1:1)
please try:
>> open wrev

Iniciar sesión para comentar.

Más respuestas (3)

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

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 13 de Jun. de 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 el 19 de Nov. de 2011
use fliplr()

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by