採用された回答

Youssef  Khmou
Youssef Khmou 2013 年 5 月 29 日

2 投票

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 件のコメント

Matthew Eicholtz
Matthew Eicholtz 2013 年 6 月 27 日
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 2013 年 6 月 28 日
wrev(vect) -> vect(end:-1:1)
please try:
>> open wrev

サインインしてコメントする。

その他の回答 (4 件)

Royi Avital
Royi Avital 2011 年 6 月 13 日

6 投票

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

3 件のコメント

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

サインインしてコメントする。

Walter Roberson
Walter Roberson 2011 年 6 月 13 日

2 投票

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 2011 年 11 月 19 日

1 投票

use fliplr()
Varshitha Gouri
Varshitha Gouri 約4時間 前

0 投票

v = [1 2 3 4 5];
reversed = flip(v);
disp(reversed);
5 4 3 2 1

Community Treasure Hunt

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

Start Hunting!

Translated by