Determine whether the vector is symmetric or not (vector could be even or odd in length).
For example:
x = [1 2 3 3 2 1] is symmetric
x = [1 2 3 4 3 2 1] is symmetric as well!
x = [-1 -2 -3 3 2 1] is not symmetric
Solution Stats
Problem Comments
5 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers1252
Suggested Problems
-
Project Euler: Problem 10, Sum of Primes
2088 Solvers
-
Back to basics 21 - Matrix replicating
1788 Solvers
-
Unique values without using UNIQUE function
440 Solvers
-
Create matrix of replicated elements
395 Solvers
-
Find out sum of all elements of given Matrix
532 Solvers
More from this Author9
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Case #3 is not symmetric...please check.
I fixed the wording.
Why the vector from "Test Suite" "Test 3" is symmetric?
x = [-1 0 0 1];
y_correct = 1; %% WHY 1?
I updated test case #3.
Hello everyone,
just a quick hint for this test: at the moment, one can pass this test simply checking whether x(1)==x(end).
However, to me at least, it makes more sense to split the check for even and odd vectors and to check if the corresponding symmetrical elements are the same or not.
If any of the pairs of elements are not equal, then we exit the cycle and we terminate with a false/0.
This is the way I figured out a robust check, otherwise it's just cheating.
KR, Andrea