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)
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
x = 1;
y_correct = 1;
assert(isequal(reverseVector(x),y_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In reverseVector (line 2)
In ScoringEngineTestPoint1 (line 3)
In solutionTest (line 3)]
|
2 | Pass |
x = -10:1;
y_correct = 1:-1:-10;
assert(isequal(reverseVector(x),y_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In reverseVector (line 2)
In ScoringEngineTestPoint2 (line 3)
In solutionTest (line 5)]
|
3 | Pass |
x = 'able was i ere i saw elba';
y_correct = 'able was i ere i saw elba';
assert(isequal(reverseVector(x),y_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In reverseVector (line 2)
In ScoringEngineTestPoint3 (line 3)
In solutionTest (line 7)]
|
Find state names that end with the letter A
708 Solvers
405 Solvers
312 Solvers
Sum all integers from 1 to 2^n
8419 Solvers
Find out sum of all elements of given Matrix
349 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!