Reverse the vector elements.
Example:
Input x = [1,2,3,4,5,6,7,8,9] Output y = [9,8,7,6,5,4,3,2,1]
Solution Stats
Problem Comments
9 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers16838
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
53342 Solvers
-
Project Euler: Problem 2, Sum of even Fibonacci
2891 Solvers
-
Permute diagonal and antidiagonal
513 Solvers
-
ベクトル [1 2 3 4 5 6 7 8 9 10] の作成
601 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
2210 Solvers
More from this Author1
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Added some more tests.
Test set needs a column vector.
As far as timing goes ...
x=rand(100,1);
tic;y=flipud(x);toc
Elapsed time is 0.068947 seconds.
tic;y=x(end:-1:1);toc
Elapsed time is 0.000026 seconds.
innovative
thanks Kristin but I got it on my own
I'm not understanding why sort(x, 'descend') is not correct. On matlab works.
GOOD
function y = rev(x)
y=sort(x,'descend');
end
i'm doing like this but i have 1 assertion error ? what's wrong?
"Iterate through the array from the last element to the first, decrementing the index by 1 in each iteration."