Cody

# Problem 742. Symmetric matrix

Solution 1929429

Submitted on 10 Sep 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
n = 0; A_correct = []; assert(isempty(your_fcn_name(n)))

Output argument "A" (and maybe others) not assigned during call to "your_fcn_name". Error in Test1 (line 3) assert(isempty(your_fcn_name(n)))

2   Pass
n = 1; A_correct = 1; assert(isequal(your_fcn_name(n),A_correct))

A = 1 A = 1

3   Fail
n= 3; A_correct =[1.0000 0.5000 0.3333 0.5000 1.0000 0.6667 0.3333 0.6667 1.0000] assert(isequal((your_fcn_name(n)-A_correct<1e-3),ones(n)))

A_correct = 1.0000 0.5000 0.3333 0.5000 1.0000 0.6667 0.3333 0.6667 1.0000 A = 1 A = 1 A = 1 2 A = 1 2 2 0 A = 1 2 3 2 0 0 A = 1 2 3 2 0 0 3 0 0 A = 1 2 3 2 1 0 3 0 0 A = 1 2 3 2 1 0 3 0 0 A = 1.0000 2.0000 3.0000 2.0000 1.0000 1.5000 3.0000 0 0 A = 1.0000 2.0000 3.0000 2.0000 1.0000 1.5000 3.0000 1.5000 0 A = 1.0000 2.0000 3.0000 2.0000 1.0000 1.5000 3.0000 1.5000 1.0000 A = 1.0000 2.0000 3.0000 2.0000 1.0000 1.5000 3.0000 1.5000 1.0000

Assertion failed.

4   Fail
n=10 A_correct =[1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.5000 1.0000 0.6667 0.5000 0.4000 0.3333 0.2857 0.2500 0.2222 0.2000 0.3333 0.6667 1.0000 0.7500 0.6000 0.5000 0.4286 0.3750 0.3333 0.3000 0.2500 0.5000 0.7500 1.0000 0.8000 0.6667 0.5714 0.5000 0.4444 0.4000 0.2000 0.4000 0.6000 0.8000 1.0000 0.8333 0.7143 0.6250 0.5556 0.5000 0.1667 0.3333 0.5000 0.6667 0.8333 1.0000 0.8571 0.7500 0.6667 0.6000 0.1429 0.2857 0.4286 0.5714 0.7143 0.8571 1.0000 0.8750 0.7778 0.7000 0.1250 0.2500 0.3750 0.5000 0.6250 0.7500 0.8750 1.0000 0.8889 0.8000 0.1111 0.2222 0.3333 0.4444 0.5556 0.6667 0.7778 0.8889 1.0000 0.9000 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000] assert(isequal((your_fcn_name(n)-A_correct<1e-3),ones(n)))

n = 10 A_correct = 1.0000 0.5000 0.3333 0.2500 0.2000 0.1667 0.1429 0.1250 0.1111 0.1000 0.5000 1.0000 0.6667 0.5000 0.4000 0.3333 0.2857 0.2500 0.2222 0.2000 0.3333 0.6667 1.0000 0.7500 0.6000 0.5000 0.4286 0.3750 0.3333 0.3000 0.2500 0.5000 0.7500 1.0000 0.8000 0.6667 0.5714 0.5000 0.4444 0.4000 0.2000 0.4000 0.6000 0.8000 1.0000 0.8333 0.7143 0.6250 0.5556 0.5000 0.1667 0.3333 0.5000 0.6667 0.8333 1.0000 0.8571 0.7500 0.6667 0.6000 0.1429 0.2857 0.4286 0.5714 0.7143 0.8571 1.0000 0.8750 0.7778 0.7000 0.1250 0.2500 0.3750 0.5000 0.6250 0.7500 0.8750 1.0000 0.8889 0.8000 0.1111 0.2222 0.3333 0.4444 0.5556 0.6667 0.7778 0.8889 1.0000 0.9000 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 A = 1 A = 1 A = 1 2 A = 1 2 2 0 A = 1 2 3 2 0 0 A = 1 2 3 2 0 0 3 0 0 A = 1 2 3 4 2 0 0 0 3 0 0 0 A = 1 2 3 4 2 0 0 0 3 0 0 0 4 0 0 0 A = 1 2 3 4 5 2 0 0 0 0 3 0 0 0 0 4 0 0 0 0 A = 1 2 3 4 5 2 0 0 0 0 3 0 0 0 0 4 0 0 0 0 5 0 0 0 0 A = 1 2 3 4 5 6 2 0 0 0 0 0 3 0 0 0 0 0 4 0 0 0 0 0 5 0 0 0 0 0 A = 1 2 3 4 5 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0 0 0 0 0 0 0 0 0 8.0000 0 0 0 0 0 0 0 0 0 9.0000 0 0 0 0 0 0 0 0 0 10.0000 0 0 0 0 0 0 0 0 0 A = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 2.0000 1.0000 1.5000 2.0000 0 0 0 0 0 0 3.0000 1.5000 0 0 0 0 0 0 0 0 4.0000 0 0 0 0 0 0 0 0 0 5.0000 0 0 0 0 0 0 0 0 0 6.0000 0 0 0 0 0 0 0 0 0 7.0000 0 0 0 0 0 0 0 0 0 8.0000 0 0 0 0 0 0 0 0 0 9.0000 0 0 0 0 0 0 0 0 0 10.0000 0 0 0 0 0 0 0 0 0 A = 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000 9.0000 10.0000 2.0000 1.0000 1.5000 ...

Assertion failed.