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.
y = flip(x);
easy
I see I'm going to have to memorize a lot of this syntax to make my life easier.
This link can help:
https://in.mathworks.com/help/matlab/ref/fliplr.html
Here is my solution;
function y = reverseVector(x)
for i=0:length(x)-1
y(1+i) = x(end-i);
end
end
y=x(end:-1:1);
y=flip(x)
I did it!
(^^)v
gj
Errors in the test suite.
This user (mohamed elbesealy) appears to have gamed the system, with fraudulent "likes" of this unremarkable solution submitted by 'sock-puppet' accounts. —DIV
Never knew about rot90. I did, y = x(length(x):-1:1) and the size was 19! Learnt something new..
That was easy
we had a similar problem in my class
easy one
how to make the code even shorter than this???
helpfull!
Test set needs a column vector.
1601 Solvers
337 Solvers
Project Euler: Problem 1, Multiples of 3 and 5
1494 Solvers
Make a run-length companion vector
512 Solvers
401 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!