how do i reverse a vector
조회 수: 555 (최근 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!