how do i reverse a vector
455 次查看(过去 30 天)
显示 更早的评论
so far i have this
function [Vout]=reverse(Vin)
0 个评论
采纳的回答
Youssef Khmou
2013-5-29
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
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?
更多回答(3 个)
Royi Avital
2011-6-13
This might work as well (For 1D Vectors):
vReversed = v(end:-1:1);
Good luck!
3 个评论
Walter Roberson
2013-6-28
Matt Eicholtz points out that Shweta's comment is incorrect; no subtraction is done, only indexing.
Walter Roberson
2011-6-13
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!