Check whether the input matrix is a normal magic square:
http://en.wikipedia.org/wiki/Magic_square
Output the logical value true or false.
This could be improved with a better test suite. For example, flipud(magic(n)) is still magical, but most of the leading solutions would return false for this.
Yes, test suite is substandard. Could have drawn from this: http://nrich.maths.org/1338
Why is magic(2) not a magic square ?
I was not notified about some of the older comments, so was unaware of some of the weaknesses of the test suite, and the "gamed" solutions. I have substantially improved the test suite.
The MATLAB command magic(2), although it does produce output, is not a magic square, according to the definition. (There is no 2x2 magic square.)
x = magic(2);
y_correct = false;
This is wrong!!!! hence solution failed
Although MATLAB does create a 2x2 matrix as an output from magic(2), that output is not a magic square.
I'm pretty sure test 5 is wrong. magic(3)+1: sum of every row, column, and both diagonals is 18
It's not a normal magic square if it's of size 3x3 and doesn't sum to 15. All rows/cols/diags must sum to n*(n^2+1)/2.
I don't think this checks the diagonals. Is that because it's not necessary?
issame is from which toolbox ?
($matlabroot)/toolbox/robust/rctobsolete/robust/issame.m
passed in matlab but not here??what ??
Test 4 is wrong: y_correct should be = TRUE
No, test 4 is correct. magic(2) does not return a magic square.
Hein? -348052801600 where does this number come from?!
Note that this gives the wrong result for magic(4). I suspect that this is tailored to the test set.
I like this since there is nothing in the MATLAB doc which guarantees that magic() produces a normal magic square. Is it necessary to also check both diagonals?
Folks, I don't get it. If you create z= magic(3)', that's a magic square. No surprise. If you then do an isequal with magic(3), you fail the test. Thus this and all solutions of this class are wrong, marked as correct only because the tests don't offer transposed magic squares as a test. The test vector needs to be fixed so all these solutions show us as not working.
Read a column of numbers and interpolate missing data
641 Solvers
3556 Solvers
116 Solvers
Who has power to do everything in this world?
246 Solvers
Add a row of zeros on top of a matrix
137 Solvers