Cody

# Problem 451. Is this matrix orthogonal?

Solution 2050418

Submitted on 8 Dec 2019
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Fail
x = orth(randn(3)); y_correct = true; assert(isequal(isOrthogonal(x),y_correct))

y = logical 0 ans = -0.9878 -0.1554 -0.0065 0.1195 -0.7316 -0.6712 0.0996 -0.6638 0.7412 ans = -0.9878 -0.1554 -0.0065 0.1195 -0.7316 -0.6712 0.0996 -0.6638 0.7412

Assertion failed.

2   Fail
x = orth(randn(4)); y_correct = true; assert(isequal(isOrthogonal(x),y_correct))

y = logical 0 ans = 0.0528 0.5346 0.2735 -0.7978 -0.6299 -0.6366 0.1046 -0.4325 0.7185 -0.5304 0.4188 -0.1643 0.2902 -0.1658 -0.8596 -0.3866 ans = 0.0528 0.5346 0.2735 -0.7978 -0.6299 -0.6366 0.1046 -0.4325 0.7185 -0.5304 0.4188 -0.1643 0.2902 -0.1658 -0.8596 -0.3866

Assertion failed.

3   Fail
x = orth(randn(5)); y_correct = true; assert(isequal(isOrthogonal(x),y_correct))

y = logical 0 ans = -0.1278 0.3806 0.8753 -0.2687 0.0207 0.0450 -0.3791 0.3932 0.6857 -0.4790 -0.3917 -0.0682 -0.1523 -0.4663 -0.7754 0.7156 -0.4850 0.1741 -0.4659 -0.0729 -0.5622 -0.6867 0.1603 -0.1522 0.4044 ans = -0.1278 0.3806 0.8753 -0.2687 0.0207 0.0450 -0.3791 0.3932 0.6857 -0.4790 -0.3917 -0.0682 -0.1523 -0.4663 -0.7754 0.7156 -0.4850 0.1741 -0.4659 -0.0729 -0.5622 -0.6867 0.1603 -0.1522 0.4044

Assertion failed.

4   Pass
x=sqrt([3,1;1,1]); y_correct = false; assert(isequal(isOrthogonal(x),y_correct))

y = logical 0 ans = 1.3660 -1.3660 -1.3660 2.3660 ans = 1.7321 1.0000 1.0000 1.0000

5   Pass
x = magic(6); y_correct = false; assert(isequal(isOrthogonal(x),y_correct))

[Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 8.001607e-19.] [> In isOrthogonal (line 2) In ScoringEngineTestPoint5 (line 3) In solutionTest (line 11) In matlab.unittest.internal.executeCodeBlock (line 11) In matlab.unittest.internal/ScriptTestCaseProvider/evaluateTestSection (line 134) In matlab.unittest.internal/ScriptTestCaseProvider/runTestSection (line 128) In matlab.unittest.internal.ScriptTestCaseProvider>@(testCase)provider.runTestSection(testCase) (line 94) In matlab.unittest/FunctionTestCase/test (line 96) In matlab.unittest/TestRunner/evaluateMethodCore (line 870) In matlab.unittest/TestRunner/evaluateMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/OutputPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/FiguresPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodsOnTestContent (line 812) In matlab.unittest/TestRunner/runTestMethod (line 1182) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/OutputPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/FiguresPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTest (line 1129) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1039) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 976) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/OutputPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/FiguresPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In matlab.unittest.plugins/DiagnosticsRecordingPlugin/runTestSuite (line 199) In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest.internal/SerialTestRunStrategy/runSession (line 21) In matlab.unittest/TestRunner/runSession (line 937) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest/TestRunner/doRunWithFcn (line 409) In matlab.unittest/TestRunner/run (line 297) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] y = logical 0 [Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 8.001607e-19.] [> In isOrthogonal (line 3) In ScoringEngineTestPoint5 (line 3) In solutionTest (line 11) In matlab.unittest.internal.executeCodeBlock (line 11) In matlab.unittest.internal/ScriptTestCaseProvider/evaluateTestSection (line 134) In matlab.unittest.internal/ScriptTestCaseProvider/runTestSection (line 128) In matlab.unittest.internal.ScriptTestCaseProvider>@(testCase)provider.runTestSection(testCase) (line 94) In matlab.unittest/FunctionTestCase/test (line 96) In matlab.unittest/TestRunner/evaluateMethodCore (line 870) In matlab.unittest/TestRunner/evaluateMethod (line 1186) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/OutputPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/evaluateMethod (line 729) In scoringengine/FiguresPlugin/evaluateMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodsOnTestContent (line 812) In matlab.unittest/TestRunner/runTestMethod (line 1182) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/OutputPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestMethod (line 648) In scoringengine/FiguresPlugin/runTestMethod In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTest (line 1129) In matlab.unittest/TestRunner/repeatTest (line 516) In matlab.unittest/TestRunner/runSharedTestCase (line 472) In matlab.unittest/TestRunner/runTestClass (line 1039) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/runTestSuite (line 976) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/OutputPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In scoringengine/FiguresPlugin/runTestSuite In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest.plugins/TestRunnerPlugin/runTestSuite (line 265) In matlab.unittest.plugins/DiagnosticsRecordingPlugin/runTestSuite (line 199) In matlab.unittest.plugins/TestRunnerPlugin/invokeTestContentOperatorMethod_ (line 760) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest.internal/SerialTestRunStrategy/runSession (line 21) In matlab.unittest/TestRunner/runSession (line 937) In matlab.unittest/TestRunner/invokeTestContentOperatorMethod_ (line 925) In matlab.unittest/TestRunner/evaluateMethodOnPlugins (line 438) In matlab.unittest/TestRunner/evaluateMethodOnPluginsFromMethodName (line 426) In matlab.unittest/TestRunner/doRunWithFcn (line 409) In matlab.unittest/TestRunner/run (line 297) In scoringengine.verifyCode In scoringengine.verifyCode In connector.internal.fevalMatlab In connector.internal.fevalJSON ] ans = 1.0e+15 * 2.2518 -0.0000 -2.2518 -2.2518 -0.0000 2.2518 2.2518 -0.0000 -2.2518 -2.2518 -0.0000 2.2518 -1.1259 0.0000 1.1259 1.1259 0.0000 -1.1259 -2.2518 0.0000 2.2518 2.2518 0.0000 -2.2518 -2.2518 0.0000 2.2518 2.2518 0.0000 -2.2518 1.1259 0 -1.1259 -1.1259 0 1.1259 ans = 35 3 31 8 30 4 1 32 9 28 5 36 6 7 2 33 34 29 26 21 22 17 12 13 19 23 27 10 14 18 24 25 20 15 16 11

6   Pass
x = randn(2)+1; y_correct = false; assert(isequal(isOrthogonal(x),y_correct))

y = logical 0 ans = 0.3481 0.4399 0.5194 -0.3037 ans = 0.9087 1.5542 1.3162 -1.0417